Class: Groonga::Object

Inherits:
Data
  • Object
show all
Defined in:
ext/groonga/rb-grn-object.c,
ext/groonga/rb-grn-object.c

Overview

rroongaが提供するクラスのベースとなるクラス。 ContextLogger 以外はGroonga::Objectを継 承している。

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean

objectother が同じGroongaのオブジェクトなら +true+ を返 し、そうでなければ +false+ を返す。

Returns:

  • (Boolean)


1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
# File 'ext/groonga/rb-grn-object.c', line 1261

static VALUE
rb_grn_object_equal (VALUE self, VALUE other)
{
    RbGrnObject *self_rb_grn_object, *other_rb_grn_object;

    if (self == other)
        return Qtrue;

    if (!RVAL2CBOOL(rb_funcall(rb_obj_class(self), rb_intern("=="), 1,
                               rb_obj_class(other))))
        return Qfalse;

    self_rb_grn_object = SELF(self);
    other_rb_grn_object = SELF(other);

    return self_rb_grn_object->object == other_rb_grn_object->object;
}

#[](id) ⇒

objectid に対応する値を返す。

Returns:

  • ()


1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
# File 'ext/groonga/rb-grn-object.c', line 1285

VALUE
rb_grn_object_array_reference (VALUE self, VALUE rb_id)
{
    VALUE exception;
    RbGrnObject *rb_grn_object;
    grn_id id, range_id;
    grn_ctx *context;
    grn_obj *object;
    grn_obj *range;
    unsigned char range_type;
    grn_obj value;
    VALUE rb_value = Qnil;

    rb_grn_object = SELF(self);
    context = rb_grn_object->context;
    object = rb_grn_object->object;
    if (!object)
        return Qnil;

    id = NUM2UINT(rb_id);
    range_id = grn_obj_get_range(context, object);
    range = grn_ctx_at(context, range_id);
    range_type = range ? range->header.type : GRN_VOID;
    switch (object->header.type) {
      case GRN_TABLE_HASH_KEY:
      case GRN_TABLE_PAT_KEY:
      case GRN_TABLE_DAT_KEY:
      case GRN_TABLE_NO_KEY:
        GRN_OBJ_INIT(&value, GRN_BULK, 0, GRN_ID_NIL);
        break;
      case GRN_TYPE:
      case GRN_ACCESSOR: /* FIXME */
        GRN_OBJ_INIT(&value, GRN_BULK, 0, range_id);
        break;
      case GRN_COLUMN_VAR_SIZE:
      case GRN_COLUMN_FIX_SIZE:
          {
              grn_column_flags column_flags;
              column_flags = grn_column_get_flags(context, object);
              switch (column_flags & GRN_OBJ_COLUMN_TYPE_MASK) {
              case GRN_OBJ_COLUMN_VECTOR:
                  GRN_OBJ_INIT(&value, GRN_VECTOR, 0, range_id);
                  break;
              case GRN_OBJ_COLUMN_SCALAR:
                  GRN_OBJ_INIT(&value, GRN_BULK, 0, range_id);
                  break;
              default:
                  rb_raise(rb_eGrnError, "unsupported column type: %u: %s",
                           range_type, rb_grn_inspect(self));
                  break;
              }
          }
          break;
      case GRN_COLUMN_INDEX:
        GRN_UINT32_INIT(&value, 0);
        break;
      default:
        rb_raise(rb_eGrnError,
                 "unsupported type: %s", rb_grn_inspect(self));
        break;
    }

    grn_obj_get_value(context, object, id, &value);
    exception = rb_grn_context_to_exception(context, self);
    if (NIL_P(exception))
        rb_value = GRNVALUE2RVAL(context, &value, range, self);
    grn_obj_unlink(context, &value);
    if (!NIL_P(exception))
        rb_exc_raise(exception);

    return rb_value;
}

#[]=(id, value) ⇒ Object

objectid に対応する値を設定する。既存の値は上書きさ れる。



1483
1484
1485
1486
1487
# File 'ext/groonga/rb-grn-object.c', line 1483

static VALUE
rb_grn_object_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
{
    return rb_grn_object_set(self, rb_id, rb_value, GRN_OBJ_SET);
}

#accessor?Boolean

Checks whether the object is accessor or not.

Returns true if the object is accessor, false otherwise.

Returns:

  • (Boolean)

    true if the object is accessor, false otherwise.

Returns:

  • (Boolean)

Since:

  • 5.1.1



1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
# File 'ext/groonga/rb-grn-object.c', line 1842

static VALUE
rb_grn_object_accessor_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool accessor_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        accessor_p = grn_obj_is_accessor(context, object);
    }

    return CBOOL2RVAL(accessor_p);
}

#append(id, value) ⇒ Object

objectid に対応する値の最後に value を追加する。



1494
1495
1496
1497
1498
# File 'ext/groonga/rb-grn-object.c', line 1494

static VALUE
rb_grn_object_append_value (VALUE self, VALUE rb_id, VALUE rb_value)
{
    return rb_grn_object_set(self, rb_id, rb_value, GRN_OBJ_APPEND);
}

#builtin?Boolean

Returns:

  • (Boolean)


1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
# File 'ext/groonga/rb-grn-object.c', line 1558

static VALUE
rb_grn_object_builtin_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool builtin = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        builtin = grn_obj_is_builtin(context, object);
    }

    return CBOOL2RVAL(builtin);
}

#closeObject

object が使用しているリソースを開放する。これ以降 object を 使うことはできない。



611
612
613
614
615
616
617
618
619
620
# File 'ext/groonga/rb-grn-object.c', line 611

VALUE
rb_grn_object_close (VALUE self)
{
    RbGrnObject *rb_grn_object;

    rb_grn_object = SELF(self);
    rb_grn_object_close_raw(rb_grn_object);

    return Qnil;
}

#closed?Boolean

object が開放済みの場合は +true+ を返し、そうでない場合は +false+ を返す。

Returns:

  • (Boolean)


654
655
656
657
658
659
660
661
662
663
664
665
# File 'ext/groonga/rb-grn-object.c', line 654

VALUE
rb_grn_object_closed_p (VALUE self)
{
    RbGrnObject *rb_grn_object;

    rb_grn_object = SELF(self);
    if (rb_grn_object->context && rb_grn_object->object) {
        return Qfalse;
    } else {
        return Qtrue;
    }
}

#column?Boolean

Checks whether the object is column or not.

Returns true if the object is column, false otherwise.

Returns:

  • (Boolean)

    true if the object is column, false otherwise.

Returns:

  • (Boolean)

Since:

  • 6.0.5



1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
# File 'ext/groonga/rb-grn-object.c', line 1608

static VALUE
rb_grn_object_column_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool column_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        column_p = grn_obj_is_column(context, object);
    }

    return CBOOL2RVAL(column_p);
}

#dirty?Boolean

Returns true if the object isn’t flushed after the last change.

Returns:

  • (Boolean)

    true if the object isn’t flushed after the last change.

Returns:

  • (Boolean)

Since:

  • 6.0.5



1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
# File 'ext/groonga/rb-grn-object.c', line 1960

static VALUE
rb_grn_object_dirty_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool is_dirty;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);
    is_dirty = grn_obj_is_dirty(context, object);
    return CBOOL2RVAL(is_dirty);
}

#domainGroonga::Object or nil

object の属している Groonga::Object を返す。例えば、 ColumnTable を返す。属している Groonga::Object がない場合は +nil+ を返す。

Returns:



1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
# File 'ext/groonga/rb-grn-object.c', line 1156

static VALUE
rb_grn_object_get_domain (VALUE self)
{
    RbGrnObject *rb_grn_object;
    grn_ctx *context;
    grn_obj *object;
    grn_id domain;

    rb_grn_object = SELF(self);
    object = rb_grn_object->object;
    if (!object)
        return Qnil;

    context = rb_grn_object->context;
    domain = object->header.domain;
    if (domain == GRN_ID_NIL) {
        return Qnil;
    } else {
        grn_obj *domain_object;

        domain_object = grn_ctx_at(context, domain);
        if (domain_object)
            return GRNOBJECT2RVAL(Qnil, context, domain_object, GRN_FALSE);
        else
            return UINT2NUM(domain);
    }
}

#function_procedure?Boolean

Checks whether the object is function procedure or not.

Returns true if the object is function procedure, false otherwise.

Returns:

  • (Boolean)

    true if the object is function procedure, false otherwise.

Returns:

  • (Boolean)

Since:

  • 5.0.1



1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
# File 'ext/groonga/rb-grn-object.c', line 1711

static VALUE
rb_grn_object_function_procedure_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool function_procedure_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        function_procedure_p = grn_obj_is_function_proc(context, object);
    }

    return CBOOL2RVAL(function_procedure_p);
}

#idID or nil

object のIDを返す。 object#closed? なときやIDがない場合は +nil+ を返す。

Returns:

  • (ID or nil)


1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
# File 'ext/groonga/rb-grn-object.c', line 1070

VALUE
rb_grn_object_get_id (VALUE self)
{
    RbGrnObject *rb_grn_object;
    grn_id id;

    rb_grn_object = SELF(self);
    if (!rb_grn_object->object)
        return Qnil;

    id = grn_obj_id(rb_grn_object->context, rb_grn_object->object);
    if (id == GRN_ID_NIL)
        return Qnil;
    else
        return UINT2NUM(id);
}

#index_column?Boolean

Checks whether the object is index column or not.

Returns true if the object is index column, false otherwise.

Returns:

  • (Boolean)

    true if the object is index column, false otherwise.

Returns:

  • (Boolean)

Since:

  • 6.0.5



1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
# File 'ext/groonga/rb-grn-object.c', line 1660

static VALUE
rb_grn_object_index_column_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool index_column_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        index_column_p = grn_obj_is_index_column(context, object);
    }

    return CBOOL2RVAL(index_column_p);
}

#inspect詳細情報

object の詳細を示した文字列を返す。デバッグ用。

Returns:

  • (詳細情報)


1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
# File 'ext/groonga/rb-grn-object.c', line 1050

static VALUE
rb_grn_object_inspect (VALUE self)
{
    VALUE inspected;

    inspected = rb_str_new_cstr("");
    rb_grn_object_inspect_header(self, inspected);
    rb_grn_object_inspect_content(self, inspected);
    rb_grn_object_inspect_footer(self, inspected);

    return inspected;
}

#key_accessor?Boolean

Checks whether the object is key accessor or not.

Examples:

true case: column("_key") is an accessor and it’s an accessor for _key

Groonga::Schema.create_table("Users", :key_type => :short_text)
users = Groonga["Users"]
users.column("_key").key_accessor? # => true

false case: column("_id") is an accessor but it’s not an accessor for _key

Groonga::Schema.create_table("Users", :key_type => :short_text)
users = Groonga["Users"]
users.column("_id").key_accessor? # => false

Returns true if the object is key accessor, false otherwise.

Returns:

  • (Boolean)

    true if the object is key accessor, false otherwise.

Returns:

  • (Boolean)

Since:

  • 5.1.1



1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
# File 'ext/groonga/rb-grn-object.c', line 1878

static VALUE
rb_grn_object_key_accessor_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool key_accessor_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        key_accessor_p = grn_obj_is_key_accessor(context, object);
    }

    return CBOOL2RVAL(key_accessor_p);
}

#last_modifiedTime

Returns The last modified time of the object.

Returns:

  • (Time)

    The last modified time of the object.

Since:

  • 6.0.5



1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
# File 'ext/groonga/rb-grn-object.c', line 1940

static VALUE
rb_grn_object_get_last_modified (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    uint32_t last_modified;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);
    last_modified = grn_obj_get_last_modified(context, object);
    return rb_funcall(rb_cTime, rb_intern("at"), 1, UINT2NUM(last_modified));
}

#name名前 or nil

object の名前を返す。無名オブジェクトの場合は +nil+ を返す。

Returns:

  • (名前 or nil)


1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
# File 'ext/groonga/rb-grn-object.c', line 1190

static VALUE
rb_grn_object_get_name (VALUE self)
{
    RbGrnObject *rb_grn_object;
    VALUE rb_name;
    char *name;
    int name_size;

    rb_grn_object = SELF(self);
    if (!rb_grn_object->object)
        return Qnil;

    name_size = grn_obj_name(rb_grn_object->context, rb_grn_object->object,
                             NULL, 0);
    if (name_size == 0)
        return Qnil;

    name = xmalloc(name_size);
    grn_obj_name(rb_grn_object->context, rb_grn_object->object,
                 name, name_size);
    rb_name = rb_str_new(name, name_size);
    xfree(name);

    return rb_name;
}

#pathファイルパス or nil

object に対応するファイルパスを返す。一時 object なら +nil+ を返す。

Returns:

  • (ファイルパス or nil)


1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
# File 'ext/groonga/rb-grn-object.c', line 1094

static VALUE
rb_grn_object_get_path (VALUE self)
{
    RbGrnObject *rb_grn_object;
    const char *path;

    rb_grn_object = SELF(self);
    if (!rb_grn_object->object)
        return Qnil;

    path = grn_obj_path(rb_grn_object->context, rb_grn_object->object);

    if (!path)
        return Qnil;
    else
        return rb_str_new_cstr(path);
}

#persistent?Boolean

object が永続オブジェクトなら +true+ 、一時オブジェクトな ら +false+ を返す。

Returns:

  • (Boolean)


1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
# File 'ext/groonga/rb-grn-object.c', line 1136

static VALUE
rb_grn_object_persistent_p (VALUE self)
{
    RbGrnObject *rb_grn_object;

    rb_grn_object = SELF(self);
    if (!rb_grn_object->object)
        return Qnil;

    return CBOOL2RVAL(rb_grn_object->object->header.flags & GRN_OBJ_PERSISTENT);
}

#prepend(id, value) ⇒ Object

objectid に対応する値の最初に value を追加する。



1505
1506
1507
1508
1509
# File 'ext/groonga/rb-grn-object.c', line 1505

static VALUE
rb_grn_object_prepend_value (VALUE self, VALUE rb_id, VALUE rb_value)
{
    return rb_grn_object_set(self, rb_id, rb_value, GRN_OBJ_PREPEND);
}

#procedure?Boolean

Checks whether the object is procedure or not.

Returns true if the object is procedure, false otherwise.

Returns:

  • (Boolean)

    true if the object is procedure, false otherwise.

Returns:

  • (Boolean)

Since:

  • 5.0.1



1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
# File 'ext/groonga/rb-grn-object.c', line 1685

static VALUE
rb_grn_object_procedure_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool procedure_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        procedure_p = grn_obj_is_proc(context, object);
    }

    return CBOOL2RVAL(procedure_p);
}

#rangeGroonga::Object or nil

object の値がとりうる範囲を示した Groonga::Object を返す。 例えば、 Column の場合は Table#define_column で指定された TypeTable を返す。 範囲が指定されていないオブジェクトの場合は +nil+ を返す。

Returns:



1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
# File 'ext/groonga/rb-grn-object.c', line 1226

static VALUE
rb_grn_object_get_range (VALUE self)
{
    RbGrnObject *rb_grn_object;
    grn_ctx *context;
    grn_obj *object;
    grn_id range;

    rb_grn_object = SELF(self);
    object = rb_grn_object->object;
    if (!object)
        return Qnil;

    context = rb_grn_object->context;
    range = grn_obj_get_range(context, object);
    if (range == GRN_ID_NIL) {
        return Qnil;
    } else {
        grn_obj *range_object;

        range_object = grn_ctx_at(context, range);
        if (range_object)
            return GRNOBJECT2RVAL(Qnil, context, range_object, GRN_FALSE);
        else
            return UINT2NUM(range);
    }
}

#reference_column?Boolean

Checks whether the object is reference column or not.

Returns true if the object is reference column, false otherwise.

Returns:

  • (Boolean)

    true if the object is reference column, false otherwise.

Returns:

  • (Boolean)

Since:

  • 6.0.5



1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
# File 'ext/groonga/rb-grn-object.c', line 1634

static VALUE
rb_grn_object_reference_column_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool reference_column_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        reference_column_p = grn_obj_is_reference_column(context, object);
    }

    return CBOOL2RVAL(reference_column_p);
}

#remove(options = {}) ⇒ Object

Free the object. If the object is persistent object, all files related with the object are removed.

Parameters:

  • options (::Hash) (defaults to: {})

    The optional parameters.

Options Hash (options):

  • :dependent (Boolean) — default: false

    If it’s true, all tables and columns that depend on the object.



1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
# File 'ext/groonga/rb-grn-object.c', line 1523

static VALUE
rb_grn_object_remove (int argc, VALUE *argv, VALUE self)
{
    RbGrnObject *rb_grn_object;
    grn_ctx *context;
    VALUE rb_options;
    VALUE rb_dependent_p;
    grn_bool dependent_p = GRN_FALSE;

    rb_grn_object = SELF(self);
    if (!rb_grn_object->object)
        return Qnil;

    rb_scan_args(argc, argv, "01", &rb_options);
    rb_grn_scan_options(rb_options,
                        "dependent", &rb_dependent_p,
                        NULL);

    if (!NIL_P(rb_dependent_p)) {
        dependent_p = RVAL2CBOOL(rb_dependent_p);
    }

    context = rb_grn_object->context;
    if (dependent_p) {
        grn_obj_remove_dependent(context, rb_grn_object->object);
    } else {
        grn_obj_remove(context, rb_grn_object->object);
    }
    rb_grn_context_check(context, self);

    rb_iv_set(self, "@context", Qnil);

    return Qnil;
}

#scorer_procedure?Boolean

Checks whether the object is scorer procedure or not.

Returns true if the object is scorer procedure, false otherwise.

Returns:

  • (Boolean)

    true if the object is scorer procedure, false otherwise.

Returns:

  • (Boolean)

Since:

  • 5.0.1



1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
# File 'ext/groonga/rb-grn-object.c', line 1789

static VALUE
rb_grn_object_scorer_procedure_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool scorer_procedure_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        scorer_procedure_p = grn_obj_is_scorer_proc(context, object);
    }

    return CBOOL2RVAL(scorer_procedure_p);
}

#selector_only_procedure?Boolean

Checks whether the object is selector only procedure or not.

Returns true if the object is selector only procedure, false otherwise.

Returns:

  • (Boolean)

    true if the object is selector only procedure, false otherwise.

Returns:

  • (Boolean)

Since:

  • 5.0.5



1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
# File 'ext/groonga/rb-grn-object.c', line 1763

static VALUE
rb_grn_object_selector_only_procedure_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool selector_only_procedure_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        selector_only_procedure_p = grn_obj_is_selector_only_proc(context, object);
    }

    return CBOOL2RVAL(selector_only_procedure_p);
}

#selector_procedure?Boolean

Checks whether the object is selector procedure or not.

Returns true if the object is selector procedure, false otherwise.

Returns:

  • (Boolean)

    true if the object is selector procedure, false otherwise.

Returns:

  • (Boolean)

Since:

  • 5.0.1



1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
# File 'ext/groonga/rb-grn-object.c', line 1737

static VALUE
rb_grn_object_selector_procedure_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool selector_procedure_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        selector_procedure_p = grn_obj_is_selector_proc(context, object);
    }

    return CBOOL2RVAL(selector_procedure_p);
}

#table?Boolean

Checks whether the object is table or not.

Returns true if the object is table, false otherwise.

Returns:

  • (Boolean)

    true if the object is table, false otherwise.

Returns:

  • (Boolean)

Since:

  • 5.0.1



1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
# File 'ext/groonga/rb-grn-object.c', line 1583

static VALUE
rb_grn_object_table_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool table_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        table_p = grn_obj_is_table(context, object);
    }

    return CBOOL2RVAL(table_p);
}

#temporary?Boolean

object が一時オブジェクトなら +true+ 、永続オブジェクトな ら +false+ を返す。

Returns:

  • (Boolean)


1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
# File 'ext/groonga/rb-grn-object.c', line 1118

static VALUE
rb_grn_object_temporary_p (VALUE self)
{
    RbGrnObject *rb_grn_object;

    rb_grn_object = SELF(self);
    if (!rb_grn_object->object)
        return Qnil;

    return CBOOL2RVAL(!(rb_grn_object->object->header.flags & GRN_OBJ_PERSISTENT));
}

#touch(time = nil) ⇒ void

Update the last modified time of the object. It’s meaningful only for persistent database, table and column.

This method returns an undefined value.

Parameters:

  • time (Time, nil) (defaults to: nil)

    (nil) The last modified time. If time is nil, the current time is used.

Since:

  • 6.0.5



1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
# File 'ext/groonga/rb-grn-object.c', line 1906

static VALUE
rb_grn_object_touch (int argc, VALUE *argv, VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    VALUE rb_time;
    grn_timeval time_buffer;
    grn_timeval *time = NULL;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);
    if (!context || !object) {
        return Qnil;
    }

    rb_scan_args(argc, argv, "01", &rb_time);
    if (!NIL_P(rb_time)) {
        time_buffer.tv_sec = NUM2LONG(rb_funcall(rb_time, rb_intern("sec"), 0));
        time_buffer.tv_nsec = NUM2INT(rb_funcall(rb_time, rb_intern("nsec"), 0));
        time = &time_buffer;
    }

    grn_obj_touch(context, object, time);
    rb_grn_context_check(context, self);

    return Qnil;
}

object のリファレンスカウンタを1減少する。



627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
# File 'ext/groonga/rb-grn-object.c', line 627

VALUE
rb_grn_object_unlink (VALUE self)
{
    RbGrnObject *rb_grn_object;
    grn_obj *object;
    grn_ctx *context;

    rb_grn_object = SELF(self);
    rb_grn_object_deconstruct(rb_grn_object, &object, &context,
                              NULL, NULL, NULL, NULL);
    if (object && context) {
        if (!(rb_grn_object->object->header.flags & GRN_OBJ_PERSISTENT)) {
            rb_grn_object_run_finalizer(context, object, rb_grn_object);
            rb_grn_object_unbind(rb_grn_object);
        }
        grn_obj_unlink(context, object);
    }

    return Qnil;
}

#window_function_procedure?Boolean

Checks whether the object is windows function procedure or not.

Returns true if the object is window function procedure, false otherwise.

Returns:

  • (Boolean)

    true if the object is window function procedure, false otherwise.

Returns:

  • (Boolean)

Since:

  • 6.0.4



1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
# File 'ext/groonga/rb-grn-object.c', line 1815

static VALUE
rb_grn_object_window_function_procedure_p (VALUE self)
{
    grn_ctx *context;
    grn_obj *object;
    grn_bool window_function_procedure_p = GRN_FALSE;

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);

    if (context && object) {
        window_function_procedure_p =
            grn_obj_is_window_function_proc(context, object);
    }

    return CBOOL2RVAL(window_function_procedure_p);
}