rroonga 3.0.5-x86-mingw32 → 3.0.6-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +5 -0
- data/Gemfile +20 -0
- data/Rakefile +187 -0
- data/doc/text/news.textile +7 -0
- data/doc/text/tutorial.textile +0 -2
- data/ext/groonga/extconf.rb +7 -1
- data/ext/groonga/rb-grn-accessor.c +11 -11
- data/ext/groonga/rb-grn-array.c +25 -25
- data/ext/groonga/rb-grn-column.c +106 -106
- data/ext/groonga/rb-grn-context.c +121 -121
- data/ext/groonga/rb-grn-database.c +78 -78
- data/ext/groonga/rb-grn-double-array-trie.c +92 -92
- data/ext/groonga/rb-grn-encoding-support.c +1 -1
- data/ext/groonga/rb-grn-encoding.c +28 -28
- data/ext/groonga/rb-grn-exception.c +9 -9
- data/ext/groonga/rb-grn-expression-builder.c +6 -6
- data/ext/groonga/rb-grn-expression.c +87 -87
- data/ext/groonga/rb-grn-fix-size-column.c +12 -12
- data/ext/groonga/rb-grn-geo-point.c +2 -2
- data/ext/groonga/rb-grn-hash.c +38 -38
- data/ext/groonga/rb-grn-index-column.c +191 -191
- data/ext/groonga/rb-grn-index-cursor.c +29 -29
- data/ext/groonga/rb-grn-logger.c +36 -36
- data/ext/groonga/rb-grn-normalizer.c +10 -10
- data/ext/groonga/rb-grn-patricia-trie.c +196 -196
- data/ext/groonga/rb-grn-plugin.c +5 -5
- data/ext/groonga/rb-grn-posting.c +2 -2
- data/ext/groonga/rb-grn-procedure.c +2 -2
- data/ext/groonga/rb-grn-query-logger.c +1 -1
- data/ext/groonga/rb-grn-record.c +1 -1
- data/ext/groonga/rb-grn-snippet.c +14 -14
- data/ext/groonga/rb-grn-table-cursor-key-support.c +4 -4
- data/ext/groonga/rb-grn-table-cursor.c +52 -52
- data/ext/groonga/rb-grn-table-key-support.c +209 -209
- data/ext/groonga/rb-grn-type.c +18 -18
- data/ext/groonga/rb-grn-utils.c +332 -314
- data/ext/groonga/rb-grn-variable-size-column.c +34 -34
- data/ext/groonga/rb-grn-variable.c +2 -2
- data/ext/groonga/rb-grn.h +240 -232
- data/ext/groonga/rb-groonga.c +10 -10
- data/lib/1.9/groonga.so +0 -0
- data/lib/2.0/groonga.so +0 -0
- data/rroonga-build.rb +7 -0
- data/rroonga.gemspec +1 -1
- data/test/test-hash.rb +4 -4
- data/test/test-index-column.rb +271 -257
- data/test/test-table-key-support.rb +78 -0
- data/test/test-table.rb +78 -51
- metadata +8 -3
@@ -37,7 +37,7 @@ grn_obj *
|
|
37
37
|
rb_grn_database_from_ruby_object (VALUE object)
|
38
38
|
{
|
39
39
|
if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnDatabase))) {
|
40
|
-
|
40
|
+
rb_raise(rb_eTypeError, "not a groonga database");
|
41
41
|
}
|
42
42
|
|
43
43
|
return RVAL2GRNOBJECT(object, NULL);
|
@@ -45,7 +45,7 @@ rb_grn_database_from_ruby_object (VALUE object)
|
|
45
45
|
|
46
46
|
VALUE
|
47
47
|
rb_grn_database_to_ruby_object (grn_ctx *context, grn_obj *database,
|
48
|
-
|
48
|
+
grn_bool owner)
|
49
49
|
{
|
50
50
|
return GRNOBJECT2RVAL(rb_cGrnDatabase, context, database, owner);
|
51
51
|
}
|
@@ -57,12 +57,12 @@ rb_grn_database_mark_existing_ruby_object (grn_ctx *context, grn_obj *database)
|
|
57
57
|
grn_id id;
|
58
58
|
|
59
59
|
cursor = grn_table_cursor_open(context, database, NULL, 0, NULL, 0,
|
60
|
-
|
60
|
+
0, -1, GRN_CURSOR_ASCENDING);
|
61
61
|
if (!cursor)
|
62
|
-
|
62
|
+
return;
|
63
63
|
|
64
64
|
while ((id = grn_table_cursor_next(context, cursor)) != GRN_ID_NIL) {
|
65
|
-
|
65
|
+
rb_grn_context_mark_grn_id(context, id);
|
66
66
|
}
|
67
67
|
grn_table_cursor_close(context, cursor);
|
68
68
|
}
|
@@ -75,12 +75,12 @@ rb_grn_database_mark (void *data)
|
|
75
75
|
grn_obj *database;
|
76
76
|
|
77
77
|
if (!rb_grn_database)
|
78
|
-
|
78
|
+
return;
|
79
79
|
|
80
80
|
context = rb_grn_database->context;
|
81
81
|
database = rb_grn_database->object;
|
82
82
|
if (!context || !database)
|
83
|
-
|
83
|
+
return;
|
84
84
|
|
85
85
|
rb_grn_database_mark_existing_ruby_object(context, database);
|
86
86
|
}
|
@@ -89,35 +89,35 @@ static VALUE
|
|
89
89
|
rb_grn_database_alloc (VALUE klass)
|
90
90
|
{
|
91
91
|
return Data_Wrap_Struct(klass, rb_grn_database_mark, rb_grn_object_free,
|
92
|
-
|
92
|
+
NULL);
|
93
93
|
}
|
94
94
|
|
95
95
|
static void
|
96
96
|
rb_grn_database_deconstruct (RbGrnObject *rb_grn_database,
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
97
|
+
grn_obj **database,
|
98
|
+
grn_ctx **context,
|
99
|
+
grn_id *domain_id,
|
100
|
+
grn_obj **domain,
|
101
|
+
grn_id *range_id,
|
102
|
+
grn_obj **range)
|
103
103
|
{
|
104
104
|
rb_grn_object_deconstruct(rb_grn_database, database, context,
|
105
|
-
|
106
|
-
|
105
|
+
domain_id, domain,
|
106
|
+
range_id, range);
|
107
107
|
}
|
108
108
|
|
109
109
|
void
|
110
110
|
rb_grn_database_finalizer (grn_ctx *context,
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
RbGrnContext *rb_grn_context,
|
112
|
+
grn_obj *column,
|
113
|
+
RbGrnObject *rb_grn_database)
|
114
114
|
{
|
115
115
|
if (rb_grn_context) {
|
116
|
-
|
116
|
+
rb_grn_context_close_floating_objects(rb_grn_context);
|
117
117
|
}
|
118
118
|
|
119
119
|
if (!(context->flags & GRN_CTX_PER_DB)) {
|
120
|
-
|
120
|
+
grn_ctx_use(context, NULL);
|
121
121
|
}
|
122
122
|
}
|
123
123
|
|
@@ -134,7 +134,7 @@ rb_grn_database_close (VALUE self)
|
|
134
134
|
|
135
135
|
rb_context = rb_iv_get(self, "@context");
|
136
136
|
if (!NIL_P(rb_context))
|
137
|
-
|
137
|
+
rb_iv_set(rb_context, "database", Qnil);
|
138
138
|
|
139
139
|
return rb_grn_object_close(self);
|
140
140
|
}
|
@@ -184,9 +184,9 @@ rb_grn_database_s_create (int argc, VALUE *argv, VALUE klass)
|
|
184
184
|
|
185
185
|
rb_grn_scan_options(options,
|
186
186
|
"path", &rb_path,
|
187
|
-
|
187
|
+
"context", &rb_context,
|
188
188
|
"builtin_type_names", &builtin_type_names,
|
189
|
-
|
189
|
+
NULL);
|
190
190
|
|
191
191
|
if (!NIL_P(rb_path))
|
192
192
|
path = StringValuePtr(rb_path);
|
@@ -197,7 +197,7 @@ rb_grn_database_s_create (int argc, VALUE *argv, VALUE klass)
|
|
197
197
|
|
198
198
|
old_database = grn_ctx_db(context);
|
199
199
|
if (old_database)
|
200
|
-
|
200
|
+
grn_obj_unlink(context, old_database);
|
201
201
|
reset_floating_objects(rb_context);
|
202
202
|
database = grn_db_create(context, path, &create_args);
|
203
203
|
rb_grn_context_check(context, rb_ary_new4(argc, argv));
|
@@ -205,12 +205,12 @@ rb_grn_database_s_create (int argc, VALUE *argv, VALUE klass)
|
|
205
205
|
rb_database = GRNOBJECT2RVAL(klass, context, database, owner);
|
206
206
|
rb_iv_set(rb_database, "@context", rb_context);
|
207
207
|
if (!NIL_P(rb_context))
|
208
|
-
|
208
|
+
rb_iv_set(rb_context, "database", rb_database);
|
209
209
|
rb_grn_context_check(context, rb_ary_new4(argc, argv));
|
210
210
|
|
211
211
|
if (rb_block_given_p())
|
212
212
|
return rb_ensure(rb_yield, rb_database,
|
213
|
-
|
213
|
+
rb_grn_database_close, rb_database);
|
214
214
|
else
|
215
215
|
return rb_database;
|
216
216
|
}
|
@@ -246,14 +246,14 @@ rb_grn_database_initialize (int argc, VALUE *argv, VALUE self)
|
|
246
246
|
|
247
247
|
path = StringValuePtr(rb_path);
|
248
248
|
rb_grn_scan_options(options,
|
249
|
-
|
250
|
-
|
249
|
+
"context", &rb_context,
|
250
|
+
NULL);
|
251
251
|
|
252
252
|
context = rb_grn_context_ensure(&rb_context);
|
253
253
|
|
254
254
|
old_database = grn_ctx_db(context);
|
255
255
|
if (old_database)
|
256
|
-
|
256
|
+
grn_obj_unlink(context, old_database);
|
257
257
|
reset_floating_objects(rb_context);
|
258
258
|
database = grn_db_open(context, path);
|
259
259
|
rb_grn_object_assign(Qnil, self, rb_context, context, database);
|
@@ -261,7 +261,7 @@ rb_grn_database_initialize (int argc, VALUE *argv, VALUE self)
|
|
261
261
|
|
262
262
|
rb_iv_set(self, "@context", rb_context);
|
263
263
|
if (!NIL_P(rb_context))
|
264
|
-
|
264
|
+
rb_iv_set(rb_context, "database", self);
|
265
265
|
|
266
266
|
return Qnil;
|
267
267
|
}
|
@@ -355,45 +355,45 @@ rb_grn_database_each (int argc, VALUE *argv, VALUE self)
|
|
355
355
|
RETURN_ENUMERATOR(self, argc, argv);
|
356
356
|
|
357
357
|
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
358
|
-
|
358
|
+
NULL, NULL, NULL, NULL);
|
359
359
|
|
360
360
|
rb_scan_args(argc, argv, "01", &rb_options);
|
361
361
|
|
362
362
|
rb_grn_scan_options(rb_options,
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
363
|
+
"order", &rb_order,
|
364
|
+
"order_by", &rb_order_by,
|
365
|
+
"ignore_missing_object", &rb_ignore_missing_object,
|
366
|
+
NULL);
|
367
367
|
|
368
368
|
flags |= rb_grn_table_cursor_order_to_flag(rb_order);
|
369
369
|
flags |= rb_grn_table_cursor_order_by_to_flag(GRN_TABLE_PAT_KEY,
|
370
|
-
|
371
|
-
|
370
|
+
self,
|
371
|
+
rb_order_by);
|
372
372
|
|
373
373
|
cursor = grn_table_cursor_open(context, database, NULL, 0, NULL, 0,
|
374
|
-
|
375
|
-
|
374
|
+
0, -1,
|
375
|
+
flags);
|
376
376
|
rb_cursor = GRNTABLECURSOR2RVAL(Qnil, context, cursor);
|
377
377
|
rb_iv_set(self, "cursor", rb_cursor);
|
378
378
|
while ((id = grn_table_cursor_next(context, cursor)) != GRN_ID_NIL) {
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
379
|
+
grn_obj *object;
|
380
|
+
|
381
|
+
object = grn_ctx_at(context, id);
|
382
|
+
if (!object && RTEST(rb_ignore_missing_object)) {
|
383
|
+
context->rc = GRN_SUCCESS;
|
384
|
+
continue;
|
385
|
+
}
|
386
|
+
|
387
|
+
exception = rb_grn_context_to_exception(context, self);
|
388
|
+
if (!NIL_P(exception)) {
|
389
|
+
rb_grn_object_close(rb_cursor);
|
390
|
+
rb_iv_set(self, "cursor", Qnil);
|
391
|
+
rb_exc_raise(exception);
|
392
|
+
}
|
393
|
+
|
394
|
+
if (object) {
|
395
|
+
rb_yield(GRNOBJECT2RVAL(Qnil, context, object, GRN_FALSE));
|
396
|
+
}
|
397
397
|
}
|
398
398
|
rb_grn_object_close(rb_cursor);
|
399
399
|
rb_iv_set(self, "cursor", Qnil);
|
@@ -414,7 +414,7 @@ rb_grn_database_unlock (VALUE self)
|
|
414
414
|
grn_rc rc;
|
415
415
|
|
416
416
|
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
417
|
-
|
417
|
+
NULL, NULL, NULL, NULL);
|
418
418
|
|
419
419
|
rc = grn_obj_unlock(context, database, GRN_ID_NIL);
|
420
420
|
rb_grn_context_check(context, self);
|
@@ -451,23 +451,23 @@ rb_grn_database_lock (int argc, VALUE *argv, VALUE self)
|
|
451
451
|
rb_scan_args(argc, argv, "01", &options);
|
452
452
|
|
453
453
|
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
454
|
-
|
454
|
+
NULL, NULL, NULL, NULL);
|
455
455
|
|
456
456
|
rb_grn_scan_options(options,
|
457
|
-
|
458
|
-
|
457
|
+
"timeout", &rb_timeout,
|
458
|
+
NULL);
|
459
459
|
|
460
460
|
if (!NIL_P(rb_timeout))
|
461
|
-
|
461
|
+
timeout = NUM2UINT(rb_timeout);
|
462
462
|
|
463
463
|
rc = grn_obj_lock(context, database, GRN_ID_NIL, timeout);
|
464
464
|
rb_grn_context_check(context, self);
|
465
465
|
rb_grn_rc_check(rc, self);
|
466
466
|
|
467
467
|
if (rb_block_given_p()) {
|
468
|
-
|
468
|
+
return rb_ensure(rb_yield, Qnil, rb_grn_database_unlock, self);
|
469
469
|
} else {
|
470
|
-
|
470
|
+
return Qnil;
|
471
471
|
}
|
472
472
|
}
|
473
473
|
|
@@ -483,7 +483,7 @@ rb_grn_database_clear_lock (VALUE self)
|
|
483
483
|
grn_obj *database;
|
484
484
|
|
485
485
|
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
486
|
-
|
486
|
+
NULL, NULL, NULL, NULL);
|
487
487
|
|
488
488
|
grn_obj_clear_lock(context, database);
|
489
489
|
|
@@ -502,7 +502,7 @@ rb_grn_database_is_locked (VALUE self)
|
|
502
502
|
grn_obj *database;
|
503
503
|
|
504
504
|
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
505
|
-
|
505
|
+
NULL, NULL, NULL, NULL);
|
506
506
|
|
507
507
|
return CBOOL2RVAL(grn_obj_is_locked(context, database));
|
508
508
|
}
|
@@ -519,7 +519,7 @@ rb_grn_database_touch (VALUE self)
|
|
519
519
|
grn_obj *database;
|
520
520
|
|
521
521
|
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
522
|
-
|
522
|
+
NULL, NULL, NULL, NULL);
|
523
523
|
|
524
524
|
grn_db_touch(context, database);
|
525
525
|
return Qnil;
|
@@ -548,14 +548,14 @@ rb_grn_database_defrag (int argc, VALUE *argv, VALUE self)
|
|
548
548
|
|
549
549
|
rb_scan_args(argc, argv, "01", &options);
|
550
550
|
rb_grn_scan_options(options,
|
551
|
-
|
552
|
-
|
551
|
+
"threshold", &rb_threshold,
|
552
|
+
NULL);
|
553
553
|
if (!NIL_P(rb_threshold)) {
|
554
|
-
|
554
|
+
threshold = NUM2INT(rb_threshold);
|
555
555
|
}
|
556
556
|
|
557
557
|
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
558
|
-
|
558
|
+
NULL, NULL, NULL, NULL);
|
559
559
|
n_segments = grn_obj_defrag(context, database, threshold);
|
560
560
|
rb_grn_context_check(context, self);
|
561
561
|
|
@@ -572,23 +572,23 @@ rb_grn_init_database (VALUE mGrn)
|
|
572
572
|
rb_include_module(rb_cGrnDatabase, rb_mGrnEncodingSupport);
|
573
573
|
|
574
574
|
rb_define_singleton_method(rb_cGrnDatabase, "create",
|
575
|
-
|
575
|
+
rb_grn_database_s_create, -1);
|
576
576
|
rb_define_singleton_method(rb_cGrnDatabase, "open",
|
577
|
-
|
577
|
+
rb_grn_database_s_open, -1);
|
578
578
|
|
579
579
|
rb_define_method(rb_cGrnDatabase, "initialize",
|
580
|
-
|
580
|
+
rb_grn_database_initialize, -1);
|
581
581
|
|
582
582
|
rb_define_method(rb_cGrnDatabase, "each",
|
583
|
-
|
583
|
+
rb_grn_database_each, -1);
|
584
584
|
|
585
585
|
rb_define_method(rb_cGrnDatabase, "close",
|
586
|
-
|
586
|
+
rb_grn_database_close, 0);
|
587
587
|
|
588
588
|
rb_define_method(rb_cGrnDatabase, "lock", rb_grn_database_lock, -1);
|
589
589
|
rb_define_method(rb_cGrnDatabase, "unlock", rb_grn_database_unlock, 0);
|
590
590
|
rb_define_method(rb_cGrnDatabase, "clear_lock",
|
591
|
-
|
591
|
+
rb_grn_database_clear_lock, 0);
|
592
592
|
rb_define_method(rb_cGrnDatabase, "locked?", rb_grn_database_is_locked, 0);
|
593
593
|
|
594
594
|
rb_define_method(rb_cGrnDatabase, "touch", rb_grn_database_touch, 0);
|
@@ -183,66 +183,66 @@ rb_grn_double_array_trie_s_create (int argc, VALUE *argv, VALUE klass)
|
|
183
183
|
rb_scan_args(argc, argv, "01", &options);
|
184
184
|
|
185
185
|
rb_grn_scan_options(options,
|
186
|
-
|
187
|
-
|
186
|
+
"context", &rb_context,
|
187
|
+
"name", &rb_name,
|
188
188
|
"path", &rb_path,
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
189
|
+
"persistent", &rb_persistent,
|
190
|
+
"key_normalize", &rb_key_normalize,
|
191
|
+
"key_with_sis", &rb_key_with_sis,
|
192
|
+
"key_type", &rb_key_type,
|
193
|
+
"value_type", &rb_value_type,
|
194
|
+
"default_tokenizer", &rb_default_tokenizer,
|
195
|
+
"sub_records", &rb_sub_records,
|
196
|
+
"normalizer", &rb_normalizer,
|
197
|
+
NULL);
|
198
198
|
|
199
199
|
context = rb_grn_context_ensure(&rb_context);
|
200
200
|
|
201
201
|
if (!NIL_P(rb_name)) {
|
202
202
|
name = StringValuePtr(rb_name);
|
203
|
-
|
204
|
-
|
203
|
+
name_size = RSTRING_LEN(rb_name);
|
204
|
+
flags |= GRN_OBJ_PERSISTENT;
|
205
205
|
}
|
206
206
|
|
207
207
|
if (!NIL_P(rb_path)) {
|
208
208
|
path = StringValueCStr(rb_path);
|
209
|
-
|
209
|
+
flags |= GRN_OBJ_PERSISTENT;
|
210
210
|
}
|
211
211
|
|
212
212
|
if (RVAL2CBOOL(rb_persistent))
|
213
|
-
|
213
|
+
flags |= GRN_OBJ_PERSISTENT;
|
214
214
|
|
215
215
|
if (RVAL2CBOOL(rb_key_normalize))
|
216
|
-
|
216
|
+
flags |= GRN_OBJ_KEY_NORMALIZE;
|
217
217
|
|
218
218
|
if (RVAL2CBOOL(rb_key_with_sis))
|
219
|
-
|
219
|
+
flags |= GRN_OBJ_KEY_WITH_SIS;
|
220
220
|
|
221
221
|
if (NIL_P(rb_key_type)) {
|
222
|
-
|
222
|
+
key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
|
223
223
|
} else {
|
224
|
-
|
224
|
+
key_type = RVAL2GRNOBJECT(rb_key_type, &context);
|
225
225
|
}
|
226
226
|
|
227
227
|
if (!NIL_P(rb_value_type))
|
228
|
-
|
228
|
+
value_type = RVAL2GRNOBJECT(rb_value_type, &context);
|
229
229
|
|
230
230
|
if (RVAL2CBOOL(rb_sub_records))
|
231
|
-
|
231
|
+
flags |= GRN_OBJ_WITH_SUBREC;
|
232
232
|
|
233
233
|
table = grn_table_create(context, name, name_size, path,
|
234
|
-
|
234
|
+
flags, key_type, value_type);
|
235
235
|
if (!table)
|
236
|
-
|
236
|
+
rb_grn_context_check(context, rb_ary_new4(argc, argv));
|
237
237
|
rb_table = GRNOBJECT2RVAL(klass, context, table, GRN_TRUE);
|
238
238
|
|
239
239
|
if (!NIL_P(rb_default_tokenizer))
|
240
|
-
|
241
|
-
|
240
|
+
rb_funcall(rb_table, rb_intern("default_tokenizer="), 1,
|
241
|
+
rb_default_tokenizer);
|
242
242
|
|
243
243
|
if (!NIL_P(rb_normalizer))
|
244
|
-
|
245
|
-
|
244
|
+
rb_funcall(rb_table, rb_intern("normalizer="), 1,
|
245
|
+
rb_normalizer);
|
246
246
|
|
247
247
|
if (rb_block_given_p())
|
248
248
|
return rb_ensure(rb_yield, rb_table, rb_grn_object_close, rb_table);
|
@@ -308,35 +308,35 @@ rb_grn_double_array_trie_search (int argc, VALUE *argv, VALUE self)
|
|
308
308
|
VALUE rb_key, options, rb_result, rb_operator, rb_type;
|
309
309
|
|
310
310
|
rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
|
311
|
-
|
312
|
-
|
313
|
-
|
311
|
+
&key, &domain_id, &domain,
|
312
|
+
NULL, NULL, NULL,
|
313
|
+
NULL);
|
314
314
|
|
315
315
|
rb_scan_args(argc, argv, "11", &rb_key, &options);
|
316
316
|
|
317
317
|
RVAL2GRNKEY(rb_key, context, key, domain_id, domain, self);
|
318
318
|
|
319
319
|
rb_grn_scan_options(options,
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
320
|
+
"result", &rb_result,
|
321
|
+
"operator", &rb_operator,
|
322
|
+
"type", &rb_type,
|
323
|
+
NULL);
|
324
324
|
|
325
325
|
if (NIL_P(rb_result)) {
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
326
|
+
result = grn_table_create(context, NULL, 0, NULL,
|
327
|
+
GRN_OBJ_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
|
328
|
+
table, 0);
|
329
|
+
rb_grn_context_check(context, self);
|
330
|
+
rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
|
331
331
|
} else {
|
332
|
-
|
332
|
+
result = RVAL2GRNOBJECT(rb_result, &context);
|
333
333
|
}
|
334
334
|
|
335
335
|
operator = RVAL2GRNOPERATOR(rb_operator);
|
336
336
|
|
337
337
|
rc = grn_obj_search(context, table, key,
|
338
|
-
|
339
|
-
|
338
|
+
result, operator,
|
339
|
+
search_options_is_set ? &search_options : NULL);
|
340
340
|
rb_grn_rc_check(rc, self);
|
341
341
|
|
342
342
|
return rb_result;
|
@@ -357,81 +357,81 @@ rb_grn_double_array_trie_open_grn_prefix_cursor (int argc, VALUE *argv,
|
|
357
357
|
VALUE rb_greater_than, rb_less_than, rb_offset, rb_limit;
|
358
358
|
|
359
359
|
rb_grn_table_deconstruct((RbGrnTable *)SELF(self), &table, context,
|
360
|
-
|
361
|
-
|
362
|
-
|
360
|
+
NULL, NULL,
|
361
|
+
NULL, NULL, NULL,
|
362
|
+
NULL);
|
363
363
|
|
364
364
|
rb_scan_args(argc, argv, "11", &rb_prefix, &options);
|
365
365
|
|
366
366
|
rb_grn_scan_options(options,
|
367
|
-
|
367
|
+
"key_bytes", &rb_key_bytes,
|
368
368
|
"key_bites", &rb_key_bits,
|
369
369
|
"offset", &rb_offset,
|
370
370
|
"limit", &rb_limit,
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
371
|
+
"order", &rb_order,
|
372
|
+
"order_by", &rb_order_by,
|
373
|
+
"greater_than", &rb_greater_than,
|
374
|
+
"less_than", &rb_less_than,
|
375
|
+
NULL);
|
376
376
|
|
377
377
|
prefix = StringValuePtr(rb_prefix);
|
378
378
|
if (!NIL_P(rb_key_bytes) && !NIL_P(rb_key_bits)) {
|
379
|
-
|
380
|
-
|
381
|
-
|
379
|
+
rb_raise(rb_eArgError,
|
380
|
+
"should not specify both :key_bytes and :key_bits once: %s",
|
381
|
+
rb_grn_inspect(rb_ary_new4(argc, argv)));
|
382
382
|
} else if (!NIL_P(rb_key_bytes)) {
|
383
|
-
|
383
|
+
prefix_size = NUM2UINT(rb_key_bytes);
|
384
384
|
} else if (!NIL_P(rb_key_bits)) {
|
385
|
-
|
386
|
-
|
385
|
+
prefix_size = NUM2UINT(rb_key_bits);
|
386
|
+
flags |= GRN_CURSOR_SIZE_BY_BIT;
|
387
387
|
} else {
|
388
|
-
|
388
|
+
prefix_size = RSTRING_LEN(rb_prefix);
|
389
389
|
}
|
390
390
|
if (!NIL_P(rb_offset))
|
391
|
-
|
391
|
+
offset = NUM2INT(rb_offset);
|
392
392
|
if (!NIL_P(rb_limit))
|
393
|
-
|
393
|
+
limit = NUM2INT(rb_limit);
|
394
394
|
|
395
395
|
if (NIL_P(rb_order)) {
|
396
396
|
} else if (rb_grn_equal_option(rb_order, "asc") ||
|
397
|
-
|
398
|
-
|
397
|
+
rb_grn_equal_option(rb_order, "ascending")) {
|
398
|
+
flags |= GRN_CURSOR_ASCENDING;
|
399
399
|
} else if (rb_grn_equal_option(rb_order, "desc") ||
|
400
|
-
|
401
|
-
|
400
|
+
rb_grn_equal_option(rb_order, "descending")) {
|
401
|
+
flags |= GRN_CURSOR_DESCENDING;
|
402
402
|
} else {
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
403
|
+
rb_raise(rb_eArgError,
|
404
|
+
"order should be one of "
|
405
|
+
"[:asc, :ascending, :desc, :descending]: %s",
|
406
|
+
rb_grn_inspect(rb_order));
|
407
407
|
}
|
408
408
|
if (NIL_P(rb_order_by)) {
|
409
409
|
} else if (rb_grn_equal_option(rb_order_by, "id")) {
|
410
|
-
|
410
|
+
flags |= GRN_CURSOR_BY_ID;
|
411
411
|
} else if (rb_grn_equal_option(rb_order_by, "key")) {
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
412
|
+
if (table->header.type != GRN_TABLE_PAT_KEY) {
|
413
|
+
rb_raise(rb_eArgError,
|
414
|
+
"order_by => :key is available "
|
415
|
+
"only for Groonga::DoubleArrayTrie: %s",
|
416
|
+
rb_grn_inspect(self));
|
417
|
+
}
|
418
|
+
flags |= GRN_CURSOR_BY_KEY;
|
419
419
|
} else {
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
420
|
+
rb_raise(rb_eArgError,
|
421
|
+
"order_by should be one of [:id%s]: %s",
|
422
|
+
table->header.type == GRN_TABLE_PAT_KEY ? ", :key" : "",
|
423
|
+
rb_grn_inspect(rb_order_by));
|
424
424
|
}
|
425
425
|
|
426
426
|
if (RVAL2CBOOL(rb_greater_than))
|
427
|
-
|
427
|
+
flags |= GRN_CURSOR_GT;
|
428
428
|
if (RVAL2CBOOL(rb_less_than))
|
429
|
-
|
429
|
+
flags |= GRN_CURSOR_LT;
|
430
430
|
|
431
431
|
cursor = grn_table_cursor_open(*context, table,
|
432
|
-
|
433
|
-
|
434
|
-
|
432
|
+
prefix, prefix_size,
|
433
|
+
NULL, 0,
|
434
|
+
offset, limit, flags);
|
435
435
|
rb_grn_context_check(*context, self);
|
436
436
|
|
437
437
|
return cursor;
|
@@ -486,28 +486,28 @@ rb_grn_double_array_trie_open_prefix_cursor (int argc, VALUE *argv, VALUE self)
|
|
486
486
|
VALUE rb_cursor;
|
487
487
|
|
488
488
|
cursor = rb_grn_double_array_trie_open_grn_prefix_cursor(argc, argv,
|
489
|
-
|
489
|
+
self, &context);
|
490
490
|
rb_cursor = GRNTABLECURSOR2RVAL(Qnil, context, cursor);
|
491
491
|
rb_iv_set(rb_cursor, "@table", self); /* FIXME: cursor should mark table */
|
492
492
|
if (rb_block_given_p())
|
493
|
-
|
493
|
+
return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
|
494
494
|
else
|
495
|
-
|
495
|
+
return rb_cursor;
|
496
496
|
}
|
497
497
|
|
498
498
|
void
|
499
499
|
rb_grn_init_double_array_trie (VALUE mGrn)
|
500
500
|
{
|
501
501
|
rb_cGrnDoubleArrayTrie =
|
502
|
-
|
502
|
+
rb_define_class_under(mGrn, "DoubleArrayTrie", rb_cGrnTable);
|
503
503
|
|
504
504
|
rb_include_module(rb_cGrnDoubleArrayTrie, rb_mGrnTableKeySupport);
|
505
505
|
rb_define_singleton_method(rb_cGrnDoubleArrayTrie, "create",
|
506
|
-
|
506
|
+
rb_grn_double_array_trie_s_create, -1);
|
507
507
|
|
508
508
|
rb_define_method(rb_cGrnDoubleArrayTrie, "search",
|
509
|
-
|
509
|
+
rb_grn_double_array_trie_search, -1);
|
510
510
|
|
511
511
|
rb_define_method(rb_cGrnDoubleArrayTrie, "open_prefix_cursor",
|
512
|
-
|
512
|
+
rb_grn_double_array_trie_open_prefix_cursor, -1);
|
513
513
|
}
|