Module: Groonga::TableCursor::KeySupport

Defined in:
ext/rb-grn-table-cursor-key-support.c,
ext/rb-grn-table-cursor-key-support.c

Overview

主キーを持つテーブル用のカーソルであるGroonga::HashCursor とGroonga::PatriciaTrieCursorに主キーの機能を提供するモジ ュール。

Instance Method Summary collapse

Instance Method Details

#keyObject

カレントレコードの主キーを返す。



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'ext/rb-grn-table-cursor-key-support.c', line 39

static VALUE
rb_grn_table_cursor_get_key (VALUE self)
{
    VALUE rb_key = Qnil;
    grn_ctx *context;
    grn_table_cursor *cursor;

    rb_grn_table_cursor_deconstruct(SELF(self), &cursor, &context,
				    NULL, NULL, NULL, NULL);
    if (context && cursor) {
        void *key;
        int key_size;
	grn_obj *table;

	table = grn_table_cursor_table(context, cursor);
        key_size = grn_table_cursor_get_key(context, cursor, &key);
        rb_key = GRNKEY2RVAL(context, key, key_size, table, self);
    }

    return rb_key;
}