Class: Groonga::FixSizeColumn

Inherits:
DataColumn show all
Defined in:
ext/groonga/rb-grn-fix-size-column.c,
ext/groonga/rb-grn-fix-size-column.c

Overview

固定長データ用のカラム。

Instance Method Summary collapse

Methods inherited from DataColumn

#apply_expression, #apply_window_function

Methods inherited from Column

#clear_lock, #data?, #disk_usage, #find_indexes, #index?, #indexes, #local_name, #lock, #locked?, #reference?, #rename, #scalar?, #select, #table, #truncate, #unlock, #vector?, #weight_vector?, #with_weight?

Methods included from Flushable

#flush

Methods inherited from Object

#==, #accessor?, #append, #builtin?, #close, #closed?, #column?, #dirty?, #domain, #function_procedure?, #id, #index_column?, #inspect, #key_accessor?, #last_modified, #name, #path, #persistent?, #prepend, #procedure?, #range, #reference_column?, #remove, #scorer_procedure?, #selector_only_procedure?, #selector_procedure?, #table?, #temporary?, #touch, #unlink, #window_function_procedure?

Instance Method Details

#column

columnid に対応する値を返す。

Returns:

  • ()


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'ext/groonga/rb-grn-fix-size-column.c', line 38

VALUE
rb_grn_fix_size_column_array_reference (VALUE self, VALUE rb_id)
{
    grn_id id;
    grn_ctx *context;
    grn_obj *fix_size_column;
    grn_obj *range;
    grn_obj *value;

    rb_grn_column_deconstruct(SELF(self), &fix_size_column, &context,
                              NULL, NULL,
                              &value, NULL, &range);

    id = NUM2UINT(rb_id);
    GRN_BULK_REWIND(value);
    grn_obj_get_value(context, fix_size_column, id, value);
    rb_grn_context_check(context, self);

    return GRNVALUE2RVAL(context, value, range, self);
}

#[]=(id, value) ⇒ Object

columnid に対応する値を設定する。

Parameters:

  • id (Integer)

    設定する値に対応する columnid

  • value (Groonga::Object)

    設定する値



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'ext/groonga/rb-grn-fix-size-column.c', line 66

static VALUE
rb_grn_fix_size_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
{
    grn_ctx *context = NULL;
    grn_obj *column;
    grn_id domain_id, range_id;
    grn_obj *domain, *range;
    grn_obj *value;
    grn_rc rc;
    grn_id id;

    rb_grn_column_deconstruct(SELF(self), &column, &context,
                              &domain_id, &domain,
                              &value, &range_id, &range);

    id = NUM2UINT(rb_id);
    RVAL2GRNVALUE(rb_value, context, value, range_id, range);

    rc = grn_obj_set_value(context, column, id, value, GRN_OBJ_SET);
    rb_grn_context_check(context, self);
    rb_grn_rc_check(rc, self);

    return Qnil;
}

#decrement!(id, delta = nil) ⇒ Object

columnid に対応する値を delta だけ減少する。 delta が +nil+ の場合は1減少する。



139
140
141
142
143
# File 'ext/groonga/rb-grn-fix-size-column.c', line 139

static VALUE
rb_grn_fix_size_column_decrement (int argc, VALUE *argv, VALUE self)
{
    return rb_grn_fix_size_column_integer_set(argc, argv, self, GRN_OBJ_DECR);
}

#increment!(id, delta = nil) ⇒ Object

columnid に対応する値を delta だけ増加する。 delta が +nil+ の場合は1増加する。



127
128
129
130
131
# File 'ext/groonga/rb-grn-fix-size-column.c', line 127

static VALUE
rb_grn_fix_size_column_increment (int argc, VALUE *argv, VALUE self)
{
    return rb_grn_fix_size_column_integer_set(argc, argv, self, GRN_OBJ_INCR);
}

#reindexvoid

Recreates all index columns for the column.

This method is useful when you have any broken index columns for the column. You don’t need to specify each index column. But this method spends more time rather than you specify only reindex needed index columns.

You can use Database#reindex to recreate all index columns in a database.

You can use TableKeySupport#reindex to recreate all index columns in a table.

You can use IndexColumn#reindex to specify the reindex target index column.

Examples:

How to recreate all index columns for the column

Groonga::Schema.define do |schema|
  schema.create_table("Users") do |table|
    table.integer32("age")
    table.integer32("score")
  end

  schema.create_table("Numbers",
                      :type => :patricia_trie,
                      :key_type => :integer32) do |table|
    table.index("Users.age")
    table.index("Users.score")
  end

  schema.create_table("Ages",
                      :type => :patricia_trie,
                      :key_type => :integer32) do |table|
    table.index("Users.age")
  end

  schema.create_table("Scores",
                      :type => :patricia_trie,
                      :key_type => :integer32) do |table|
    table.index("Users.score")
  end
end

Groonga["Users.age"].reindex
# They are called:
#   Groonga["Numbers.Users_age"].reindex
#   Groonga["Ages.Users_age"].reindex
#
# They aren't called:
#   Groonga["Numbers.Users_score"].reindex
#   Groonga["Scores.Users_score"].reindex

This method returns an undefined value.

See Also:

Since:

  • 5.1.1



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'ext/groonga/rb-grn-fix-size-column.c', line 208

static VALUE
rb_grn_fix_size_column_reindex (VALUE self)
{
    grn_rc rc;
    grn_ctx *context;
    grn_obj *column;

    rb_grn_column_deconstruct(SELF(self), &column, &context,
                              NULL, NULL,
                              NULL, NULL, NULL);

    rc = grn_obj_reindex(context, column);
    rb_grn_context_check(context, self);
    rb_grn_rc_check(rc, self);

    return Qnil;
}