Class: Groonga::IndexCursor

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
ext/groonga/rb-grn-index-cursor.c

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#==, #[], #[]=, #accessor?, #append, #builtin?, #bulk?, #close, #closed?, #column?, #corrupt?, #dirty?, #disk_usage, #domain, #function_procedure?, #id, #id_accessor?, #index_column?, #inspect, #key_accessor?, #last_modified, #lexicon?, #n_sub_records_accessor?, #name, #path, #persistent?, #prepend, #procedure?, #range, #reference_column?, #remove, #score_accessor?, #scorer_procedure?, #selector_only_procedure?, #selector_procedure?, #table?, #temporary?, #touch, #unlink, #value_accessor?, #window_function_procedure?

Class Method Details

.set_min=Object



66
67
68
69
70
71
# File 'ext/groonga/rb-grn-index-cursor.c', line 66

static VALUE
rb_grn_index_cursor_s_set_min_set (VALUE klass, VALUE enable)
{
    grn_ii_cursor_set_min_enable_set(RVAL2CBOOL(enable));
    return enable;
}

.set_min?Boolean

Returns:

  • (Boolean)


60
61
62
63
64
# File 'ext/groonga/rb-grn-index-cursor.c', line 60

static VALUE
rb_grn_index_cursor_s_set_min_p (VALUE klass)
{
    return CBOOL2RVAL(grn_ii_cursor_set_min_enable_get());
}

Instance Method Details

#eachObject



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'ext/groonga/rb-grn-index-cursor.c', line 114

static VALUE
rb_grn_index_cursor_each (int argc, VALUE *argv, VALUE self)
{
    grn_obj *cursor;
    grn_ctx *context;
    grn_bool reuse_posting_object;
    VALUE rb_options;
    VALUE rb_reuse_posting_object;
    VALUE rb_table;
    VALUE rb_lexicon;
    VALUE rb_posting = Qnil;

    RETURN_ENUMERATOR(self, argc, argv);

    rb_scan_args(argc, argv, "01", &rb_options);

    rb_grn_scan_options(rb_options,
                        "reuse_posting_object", &rb_reuse_posting_object,
                        NULL);

    rb_grn_index_cursor_deconstruct(SELF(self), &cursor, &context,
                                    NULL, NULL, NULL, NULL);

    if (!context) {
        return Qnil;
    }

    if (!cursor) {
        return Qnil;
    }

    rb_table = rb_iv_get(self, "@table");
    rb_lexicon = rb_iv_get(self, "@lexicon");
    reuse_posting_object = RVAL2CBOOL(rb_reuse_posting_object);

    if (reuse_posting_object) {
        rb_posting = rb_grn_posting_new(NULL, GRN_ID_NIL, rb_table, rb_lexicon);
    }
    while (GRN_TRUE) {
        if (!reuse_posting_object) {
            rb_posting = Qnil;
        }
        rb_posting = next_value(rb_posting,
                                context, cursor, rb_table, rb_lexicon);
        if (NIL_P(rb_posting)) {
            break;
        }
        rb_yield(rb_posting);
    }

    return Qnil;
}

#nextObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'ext/groonga/rb-grn-index-cursor.c', line 93

static VALUE
rb_grn_index_cursor_next (VALUE self)
{
    VALUE rb_posting = Qnil;
    grn_obj *cursor;
    grn_ctx *context;

    rb_grn_index_cursor_deconstruct(SELF(self), &cursor, &context,
                                    NULL, NULL, NULL, NULL);
    if (context && cursor) {
        VALUE rb_table;
        VALUE rb_lexicon;
        rb_table = rb_iv_get(self, "@table");
        rb_lexicon = rb_iv_get(self, "@lexicon");
        rb_posting = next_value(Qnil, context, cursor, rb_table, rb_lexicon);
    }

    return rb_posting;

}