rroonga 3.0.5 → 3.0.6

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.
Files changed (48) hide show
  1. data/AUTHORS +5 -0
  2. data/Gemfile +20 -0
  3. data/Rakefile +187 -0
  4. data/doc/text/news.textile +10 -2
  5. data/doc/text/tutorial.textile +0 -2
  6. data/ext/groonga/extconf.rb +7 -1
  7. data/ext/groonga/rb-grn-accessor.c +11 -11
  8. data/ext/groonga/rb-grn-array.c +25 -25
  9. data/ext/groonga/rb-grn-column.c +106 -106
  10. data/ext/groonga/rb-grn-context.c +121 -121
  11. data/ext/groonga/rb-grn-database.c +78 -78
  12. data/ext/groonga/rb-grn-double-array-trie.c +92 -92
  13. data/ext/groonga/rb-grn-encoding-support.c +1 -1
  14. data/ext/groonga/rb-grn-encoding.c +28 -28
  15. data/ext/groonga/rb-grn-exception.c +9 -9
  16. data/ext/groonga/rb-grn-expression-builder.c +6 -6
  17. data/ext/groonga/rb-grn-expression.c +87 -87
  18. data/ext/groonga/rb-grn-fix-size-column.c +12 -12
  19. data/ext/groonga/rb-grn-geo-point.c +2 -2
  20. data/ext/groonga/rb-grn-hash.c +38 -38
  21. data/ext/groonga/rb-grn-index-column.c +191 -191
  22. data/ext/groonga/rb-grn-index-cursor.c +29 -29
  23. data/ext/groonga/rb-grn-logger.c +36 -36
  24. data/ext/groonga/rb-grn-normalizer.c +10 -10
  25. data/ext/groonga/rb-grn-patricia-trie.c +196 -196
  26. data/ext/groonga/rb-grn-plugin.c +5 -5
  27. data/ext/groonga/rb-grn-posting.c +2 -2
  28. data/ext/groonga/rb-grn-procedure.c +2 -2
  29. data/ext/groonga/rb-grn-query-logger.c +1 -1
  30. data/ext/groonga/rb-grn-record.c +1 -1
  31. data/ext/groonga/rb-grn-snippet.c +14 -14
  32. data/ext/groonga/rb-grn-table-cursor-key-support.c +4 -4
  33. data/ext/groonga/rb-grn-table-cursor.c +52 -52
  34. data/ext/groonga/rb-grn-table-key-support.c +209 -209
  35. data/ext/groonga/rb-grn-type.c +18 -18
  36. data/ext/groonga/rb-grn-utils.c +332 -314
  37. data/ext/groonga/rb-grn-variable-size-column.c +34 -34
  38. data/ext/groonga/rb-grn-variable.c +2 -2
  39. data/ext/groonga/rb-grn.h +240 -232
  40. data/ext/groonga/rb-groonga.c +10 -10
  41. data/rroonga-build.rb +7 -0
  42. data/rroonga.gemspec +1 -1
  43. data/test/test-hash.rb +4 -4
  44. data/test/test-index-column.rb +271 -257
  45. data/test/test-table-key-support.rb +78 -0
  46. data/test/test-table.rb +78 -51
  47. metadata +195 -164
  48. checksums.yaml +0 -7
@@ -174,65 +174,65 @@ rb_grn_patricia_trie_s_create (int argc, VALUE *argv, VALUE klass)
174
174
  rb_scan_args(argc, argv, "01", &options);
175
175
 
176
176
  rb_grn_scan_options(options,
177
- "context", &rb_context,
178
- "name", &rb_name,
177
+ "context", &rb_context,
178
+ "name", &rb_name,
179
179
  "path", &rb_path,
180
- "persistent", &rb_persistent,
181
- "key_normalize", &rb_key_normalize,
182
- "key_with_sis", &rb_key_with_sis,
183
- "key_type", &rb_key_type,
184
- "value_type", &rb_value_type,
185
- "default_tokenizer", &rb_default_tokenizer,
186
- "sub_records", &rb_sub_records,
187
- "normalizer", &rb_normalizer,
188
- NULL);
180
+ "persistent", &rb_persistent,
181
+ "key_normalize", &rb_key_normalize,
182
+ "key_with_sis", &rb_key_with_sis,
183
+ "key_type", &rb_key_type,
184
+ "value_type", &rb_value_type,
185
+ "default_tokenizer", &rb_default_tokenizer,
186
+ "sub_records", &rb_sub_records,
187
+ "normalizer", &rb_normalizer,
188
+ NULL);
189
189
 
190
190
  context = rb_grn_context_ensure(&rb_context);
191
191
 
192
192
  if (!NIL_P(rb_name)) {
193
193
  name = StringValuePtr(rb_name);
194
- name_size = RSTRING_LEN(rb_name);
195
- flags |= GRN_OBJ_PERSISTENT;
194
+ name_size = RSTRING_LEN(rb_name);
195
+ flags |= GRN_OBJ_PERSISTENT;
196
196
  }
197
197
 
198
198
  if (!NIL_P(rb_path)) {
199
199
  path = StringValueCStr(rb_path);
200
- flags |= GRN_OBJ_PERSISTENT;
200
+ flags |= GRN_OBJ_PERSISTENT;
201
201
  }
202
202
 
203
203
  if (RVAL2CBOOL(rb_persistent))
204
- flags |= GRN_OBJ_PERSISTENT;
204
+ flags |= GRN_OBJ_PERSISTENT;
205
205
 
206
206
  if (RVAL2CBOOL(rb_key_normalize))
207
- flags |= GRN_OBJ_KEY_NORMALIZE;
207
+ flags |= GRN_OBJ_KEY_NORMALIZE;
208
208
 
209
209
  if (RVAL2CBOOL(rb_key_with_sis))
210
- flags |= GRN_OBJ_KEY_WITH_SIS;
210
+ flags |= GRN_OBJ_KEY_WITH_SIS;
211
211
 
212
212
  if (NIL_P(rb_key_type)) {
213
- key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
213
+ key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
214
214
  } else {
215
- key_type = RVAL2GRNOBJECT(rb_key_type, &context);
215
+ key_type = RVAL2GRNOBJECT(rb_key_type, &context);
216
216
  }
217
217
 
218
218
  if (!NIL_P(rb_value_type))
219
- value_type = RVAL2GRNOBJECT(rb_value_type, &context);
219
+ value_type = RVAL2GRNOBJECT(rb_value_type, &context);
220
220
 
221
221
  if (RVAL2CBOOL(rb_sub_records))
222
- flags |= GRN_OBJ_WITH_SUBREC;
222
+ flags |= GRN_OBJ_WITH_SUBREC;
223
223
 
224
224
  table = grn_table_create(context, name, name_size, path,
225
- flags, key_type, value_type);
225
+ flags, key_type, value_type);
226
226
  if (!table)
227
- rb_grn_context_check(context, rb_ary_new4(argc, argv));
227
+ rb_grn_context_check(context, rb_ary_new4(argc, argv));
228
228
  rb_table = GRNOBJECT2RVAL(klass, context, table, GRN_TRUE);
229
229
 
230
230
  if (!NIL_P(rb_default_tokenizer))
231
- rb_funcall(rb_table, rb_intern("default_tokenizer="), 1,
232
- rb_default_tokenizer);
231
+ rb_funcall(rb_table, rb_intern("default_tokenizer="), 1,
232
+ rb_default_tokenizer);
233
233
  if (!NIL_P(rb_normalizer))
234
- rb_funcall(rb_table, rb_intern("normalizer="), 1,
235
- rb_normalizer);
234
+ rb_funcall(rb_table, rb_intern("normalizer="), 1,
235
+ rb_normalizer);
236
236
 
237
237
  if (rb_block_given_p())
238
238
  return rb_ensure(rb_yield, rb_table, rb_grn_object_close, rb_table);
@@ -296,35 +296,35 @@ rb_grn_patricia_trie_search (int argc, VALUE *argv, VALUE self)
296
296
  VALUE rb_key, options, rb_result, rb_operator, rb_type;
297
297
 
298
298
  rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
299
- &key, &domain_id, &domain,
300
- NULL, NULL, NULL,
301
- NULL);
299
+ &key, &domain_id, &domain,
300
+ NULL, NULL, NULL,
301
+ NULL);
302
302
 
303
303
  rb_scan_args(argc, argv, "11", &rb_key, &options);
304
304
 
305
305
  RVAL2GRNKEY(rb_key, context, key, domain_id, domain, self);
306
306
 
307
307
  rb_grn_scan_options(options,
308
- "result", &rb_result,
309
- "operator", &rb_operator,
310
- "type", &rb_type,
311
- NULL);
308
+ "result", &rb_result,
309
+ "operator", &rb_operator,
310
+ "type", &rb_type,
311
+ NULL);
312
312
 
313
313
  if (NIL_P(rb_result)) {
314
- result = grn_table_create(context, NULL, 0, NULL,
315
- GRN_OBJ_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
316
- table, 0);
317
- rb_grn_context_check(context, self);
318
- rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
314
+ result = grn_table_create(context, NULL, 0, NULL,
315
+ GRN_OBJ_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
316
+ table, 0);
317
+ rb_grn_context_check(context, self);
318
+ rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
319
319
  } else {
320
- result = RVAL2GRNOBJECT(rb_result, &context);
320
+ result = RVAL2GRNOBJECT(rb_result, &context);
321
321
  }
322
322
 
323
323
  operator = RVAL2GRNOPERATOR(rb_operator);
324
324
 
325
325
  rc = grn_obj_search(context, table, key,
326
- result, operator,
327
- search_options_is_set ? &search_options : NULL);
326
+ result, operator,
327
+ search_options_is_set ? &search_options : NULL);
328
328
  rb_grn_rc_check(rc, self);
329
329
 
330
330
  return rb_result;
@@ -384,47 +384,47 @@ rb_grn_patricia_trie_scan (VALUE self, VALUE rb_string)
384
384
  string_length = RSTRING_LEN(rb_string);
385
385
 
386
386
  rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
387
- NULL, NULL, NULL,
388
- NULL, NULL, NULL,
389
- NULL);
387
+ NULL, NULL, NULL,
388
+ NULL, NULL, NULL,
389
+ NULL);
390
390
 
391
391
  block_given = rb_block_given_p();
392
392
  if (!block_given)
393
- rb_result = rb_ary_new();
393
+ rb_result = rb_ary_new();
394
394
 
395
395
  while (string_length > 0) {
396
- const char *rest;
397
- int i, n_hits;
398
- unsigned int previous_offset = 0;
399
-
400
- n_hits = grn_pat_scan(context, (grn_pat *)table,
401
- string, string_length,
402
- hits, sizeof(hits) / sizeof(*hits),
403
- &rest);
404
- for (i = 0; i < n_hits; i++) {
405
- VALUE record, term, matched_info;
406
-
407
- if (hits[i].offset < previous_offset)
408
- continue;
409
-
410
- record = rb_grn_record_new(self, hits[i].id, Qnil);
411
- term = rb_grn_context_rb_string_new(context,
412
- string + hits[i].offset,
413
- hits[i].length);
414
- matched_info = rb_ary_new3(4,
415
- record,
416
- term,
417
- UINT2NUM(hits[i].offset),
418
- UINT2NUM(hits[i].length));
419
- if (block_given) {
420
- rb_yield(matched_info);
421
- } else {
422
- rb_ary_push(rb_result, matched_info);
423
- }
424
- previous_offset = hits[i].offset;
425
- }
426
- string_length -= rest - string;
427
- string = rest;
396
+ const char *rest;
397
+ int i, n_hits;
398
+ unsigned int previous_offset = 0;
399
+
400
+ n_hits = grn_pat_scan(context, (grn_pat *)table,
401
+ string, string_length,
402
+ hits, sizeof(hits) / sizeof(*hits),
403
+ &rest);
404
+ for (i = 0; i < n_hits; i++) {
405
+ VALUE record, term, matched_info;
406
+
407
+ if (hits[i].offset < previous_offset)
408
+ continue;
409
+
410
+ record = rb_grn_record_new(self, hits[i].id, Qnil);
411
+ term = rb_grn_context_rb_string_new(context,
412
+ string + hits[i].offset,
413
+ hits[i].length);
414
+ matched_info = rb_ary_new3(4,
415
+ record,
416
+ term,
417
+ UINT2NUM(hits[i].offset),
418
+ UINT2NUM(hits[i].length));
419
+ if (block_given) {
420
+ rb_yield(matched_info);
421
+ } else {
422
+ rb_ary_push(rb_result, matched_info);
423
+ }
424
+ previous_offset = hits[i].offset;
425
+ }
426
+ string_length -= rest - string;
427
+ string = rest;
428
428
  }
429
429
 
430
430
  return rb_result;
@@ -447,21 +447,21 @@ rb_grn_patricia_trie_prefix_search (VALUE self, VALUE rb_prefix)
447
447
  VALUE rb_result;
448
448
 
449
449
  rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
450
- &key, &domain_id, &domain,
451
- NULL, NULL, NULL,
452
- NULL);
450
+ &key, &domain_id, &domain,
451
+ NULL, NULL, NULL,
452
+ NULL);
453
453
 
454
454
  result = grn_table_create(context, NULL, 0, NULL,
455
- GRN_OBJ_TABLE_HASH_KEY,
456
- table, 0);
455
+ GRN_OBJ_TABLE_HASH_KEY,
456
+ table, 0);
457
457
  rb_grn_context_check(context, self);
458
458
  rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
459
459
 
460
460
  GRN_BULK_REWIND(key);
461
461
  RVAL2GRNKEY(rb_prefix, context, key, domain_id, domain, self);
462
462
  grn_pat_prefix_search(context, (grn_pat *)table,
463
- GRN_BULK_HEAD(key), GRN_BULK_VSIZE(key),
464
- (grn_hash *)result);
463
+ GRN_BULK_HEAD(key), GRN_BULK_VSIZE(key),
464
+ (grn_hash *)result);
465
465
  rb_grn_context_check(context, self);
466
466
 
467
467
  return rb_result;
@@ -479,15 +479,15 @@ rb_grn_patricia_trie_register_key_with_sis_p (VALUE self)
479
479
  grn_obj *table;
480
480
 
481
481
  rb_grn_table_key_support_deconstruct(SELF(self), &table, NULL,
482
- NULL, NULL, NULL,
483
- NULL, NULL, NULL,
484
- NULL);
482
+ NULL, NULL, NULL,
483
+ NULL, NULL, NULL,
484
+ NULL);
485
485
  return CBOOL2RVAL(table->header.flags & GRN_OBJ_KEY_WITH_SIS);
486
486
  }
487
487
 
488
488
  static grn_table_cursor *
489
489
  rb_grn_patricia_trie_open_grn_prefix_cursor (int argc, VALUE *argv, VALUE self,
490
- grn_ctx **context)
490
+ grn_ctx **context)
491
491
  {
492
492
  grn_obj *table;
493
493
  grn_table_cursor *cursor;
@@ -500,81 +500,81 @@ rb_grn_patricia_trie_open_grn_prefix_cursor (int argc, VALUE *argv, VALUE self,
500
500
  VALUE rb_greater_than, rb_less_than, rb_offset, rb_limit;
501
501
 
502
502
  rb_grn_table_deconstruct((RbGrnTable *)SELF(self), &table, context,
503
- NULL, NULL,
504
- NULL, NULL, NULL,
505
- NULL);
503
+ NULL, NULL,
504
+ NULL, NULL, NULL,
505
+ NULL);
506
506
 
507
507
  rb_scan_args(argc, argv, "11", &rb_prefix, &options);
508
508
 
509
509
  rb_grn_scan_options(options,
510
- "key_bytes", &rb_key_bytes,
510
+ "key_bytes", &rb_key_bytes,
511
511
  "key_bites", &rb_key_bits,
512
512
  "offset", &rb_offset,
513
513
  "limit", &rb_limit,
514
- "order", &rb_order,
515
- "order_by", &rb_order_by,
516
- "greater_than", &rb_greater_than,
517
- "less_than", &rb_less_than,
518
- NULL);
514
+ "order", &rb_order,
515
+ "order_by", &rb_order_by,
516
+ "greater_than", &rb_greater_than,
517
+ "less_than", &rb_less_than,
518
+ NULL);
519
519
 
520
520
  prefix = StringValuePtr(rb_prefix);
521
521
  if (!NIL_P(rb_key_bytes) && !NIL_P(rb_key_bits)) {
522
- rb_raise(rb_eArgError,
523
- "should not specify both :key_bytes and :key_bits once: %s",
524
- rb_grn_inspect(rb_ary_new4(argc, argv)));
522
+ rb_raise(rb_eArgError,
523
+ "should not specify both :key_bytes and :key_bits once: %s",
524
+ rb_grn_inspect(rb_ary_new4(argc, argv)));
525
525
  } else if (!NIL_P(rb_key_bytes)) {
526
- prefix_size = NUM2UINT(rb_key_bytes);
526
+ prefix_size = NUM2UINT(rb_key_bytes);
527
527
  } else if (!NIL_P(rb_key_bits)) {
528
- prefix_size = NUM2UINT(rb_key_bits);
529
- flags |= GRN_CURSOR_SIZE_BY_BIT;
528
+ prefix_size = NUM2UINT(rb_key_bits);
529
+ flags |= GRN_CURSOR_SIZE_BY_BIT;
530
530
  } else {
531
- prefix_size = RSTRING_LEN(rb_prefix);
531
+ prefix_size = RSTRING_LEN(rb_prefix);
532
532
  }
533
533
  if (!NIL_P(rb_offset))
534
- offset = NUM2INT(rb_offset);
534
+ offset = NUM2INT(rb_offset);
535
535
  if (!NIL_P(rb_limit))
536
- limit = NUM2INT(rb_limit);
536
+ limit = NUM2INT(rb_limit);
537
537
 
538
538
  if (NIL_P(rb_order)) {
539
539
  } else if (rb_grn_equal_option(rb_order, "asc") ||
540
- rb_grn_equal_option(rb_order, "ascending")) {
541
- flags |= GRN_CURSOR_ASCENDING;
540
+ rb_grn_equal_option(rb_order, "ascending")) {
541
+ flags |= GRN_CURSOR_ASCENDING;
542
542
  } else if (rb_grn_equal_option(rb_order, "desc") ||
543
- rb_grn_equal_option(rb_order, "descending")) {
544
- flags |= GRN_CURSOR_DESCENDING;
543
+ rb_grn_equal_option(rb_order, "descending")) {
544
+ flags |= GRN_CURSOR_DESCENDING;
545
545
  } else {
546
- rb_raise(rb_eArgError,
547
- "order should be one of "
548
- "[:asc, :ascending, :desc, :descending]: %s",
549
- rb_grn_inspect(rb_order));
546
+ rb_raise(rb_eArgError,
547
+ "order should be one of "
548
+ "[:asc, :ascending, :desc, :descending]: %s",
549
+ rb_grn_inspect(rb_order));
550
550
  }
551
551
  if (NIL_P(rb_order_by)) {
552
552
  } else if (rb_grn_equal_option(rb_order_by, "id")) {
553
- flags |= GRN_CURSOR_BY_ID;
553
+ flags |= GRN_CURSOR_BY_ID;
554
554
  } else if (rb_grn_equal_option(rb_order_by, "key")) {
555
- if (table->header.type != GRN_TABLE_PAT_KEY) {
556
- rb_raise(rb_eArgError,
557
- "order_by => :key is available "
558
- "only for Groonga::PatriciaTrie: %s",
559
- rb_grn_inspect(self));
560
- }
561
- flags |= GRN_CURSOR_BY_KEY;
555
+ if (table->header.type != GRN_TABLE_PAT_KEY) {
556
+ rb_raise(rb_eArgError,
557
+ "order_by => :key is available "
558
+ "only for Groonga::PatriciaTrie: %s",
559
+ rb_grn_inspect(self));
560
+ }
561
+ flags |= GRN_CURSOR_BY_KEY;
562
562
  } else {
563
- rb_raise(rb_eArgError,
564
- "order_by should be one of [:id%s]: %s",
565
- table->header.type == GRN_TABLE_PAT_KEY ? ", :key" : "",
566
- rb_grn_inspect(rb_order_by));
563
+ rb_raise(rb_eArgError,
564
+ "order_by should be one of [:id%s]: %s",
565
+ table->header.type == GRN_TABLE_PAT_KEY ? ", :key" : "",
566
+ rb_grn_inspect(rb_order_by));
567
567
  }
568
568
 
569
569
  if (RVAL2CBOOL(rb_greater_than))
570
- flags |= GRN_CURSOR_GT;
570
+ flags |= GRN_CURSOR_GT;
571
571
  if (RVAL2CBOOL(rb_less_than))
572
- flags |= GRN_CURSOR_LT;
572
+ flags |= GRN_CURSOR_LT;
573
573
 
574
574
  cursor = grn_table_cursor_open(*context, table,
575
- prefix, prefix_size,
576
- NULL, 0,
577
- offset, limit, flags);
575
+ prefix, prefix_size,
576
+ NULL, 0,
577
+ offset, limit, flags);
578
578
  rb_grn_context_check(*context, self);
579
579
 
580
580
  return cursor;
@@ -629,18 +629,18 @@ rb_grn_patricia_trie_open_prefix_cursor (int argc, VALUE *argv, VALUE self)
629
629
  VALUE rb_cursor;
630
630
 
631
631
  cursor = rb_grn_patricia_trie_open_grn_prefix_cursor(argc, argv,
632
- self, &context);
632
+ self, &context);
633
633
  rb_cursor = GRNTABLECURSOR2RVAL(Qnil, context, cursor);
634
634
  rb_iv_set(rb_cursor, "@table", self); /* FIXME: cursor should mark table */
635
635
  if (rb_block_given_p())
636
- return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
636
+ return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
637
637
  else
638
- return rb_cursor;
638
+ return rb_cursor;
639
639
  }
640
640
 
641
641
  static grn_table_cursor *
642
642
  rb_grn_patricia_trie_open_grn_rk_cursor (int argc, VALUE *argv, VALUE self,
643
- grn_ctx **context)
643
+ grn_ctx **context)
644
644
  {
645
645
  grn_obj *table;
646
646
  grn_table_cursor *cursor;
@@ -652,48 +652,48 @@ rb_grn_patricia_trie_open_grn_rk_cursor (int argc, VALUE *argv, VALUE self,
652
652
  VALUE rb_greater_than, rb_less_than, rb_offset, rb_limit;
653
653
 
654
654
  rb_grn_table_deconstruct((RbGrnTable *)SELF(self), &table, context,
655
- NULL, NULL,
656
- NULL, NULL, NULL,
657
- NULL);
655
+ NULL, NULL,
656
+ NULL, NULL, NULL,
657
+ NULL);
658
658
 
659
659
  rb_scan_args(argc, argv, "11", &rb_prefix, &options);
660
660
 
661
661
  rb_grn_scan_options(options,
662
- "key_bytes", &rb_key_bytes,
662
+ "key_bytes", &rb_key_bytes,
663
663
  "key_bites", &rb_key_bits,
664
664
  "offset", &rb_offset,
665
665
  "limit", &rb_limit,
666
- "greater_than", &rb_greater_than,
667
- "less_than", &rb_less_than,
668
- NULL);
666
+ "greater_than", &rb_greater_than,
667
+ "less_than", &rb_less_than,
668
+ NULL);
669
669
 
670
670
  prefix = StringValuePtr(rb_prefix);
671
671
  if (!NIL_P(rb_key_bytes) && !NIL_P(rb_key_bits)) {
672
- rb_raise(rb_eArgError,
673
- "should not specify both :key_bytes and :key_bits once: %s",
674
- rb_grn_inspect(rb_ary_new4(argc, argv)));
672
+ rb_raise(rb_eArgError,
673
+ "should not specify both :key_bytes and :key_bits once: %s",
674
+ rb_grn_inspect(rb_ary_new4(argc, argv)));
675
675
  } else if (!NIL_P(rb_key_bytes)) {
676
- prefix_size = NUM2UINT(rb_key_bytes);
676
+ prefix_size = NUM2UINT(rb_key_bytes);
677
677
  } else if (!NIL_P(rb_key_bits)) {
678
- prefix_size = NUM2UINT(rb_key_bits);
679
- flags |= GRN_CURSOR_SIZE_BY_BIT;
678
+ prefix_size = NUM2UINT(rb_key_bits);
679
+ flags |= GRN_CURSOR_SIZE_BY_BIT;
680
680
  } else {
681
- prefix_size = RSTRING_LEN(rb_prefix);
681
+ prefix_size = RSTRING_LEN(rb_prefix);
682
682
  }
683
683
  if (!NIL_P(rb_offset))
684
- offset = NUM2INT(rb_offset);
684
+ offset = NUM2INT(rb_offset);
685
685
  if (!NIL_P(rb_limit))
686
- limit = NUM2INT(rb_limit);
686
+ limit = NUM2INT(rb_limit);
687
687
 
688
688
  if (RVAL2CBOOL(rb_greater_than))
689
- flags |= GRN_CURSOR_GT;
689
+ flags |= GRN_CURSOR_GT;
690
690
  if (RVAL2CBOOL(rb_less_than))
691
- flags |= GRN_CURSOR_LT;
691
+ flags |= GRN_CURSOR_LT;
692
692
 
693
693
  cursor = grn_table_cursor_open(*context, table,
694
- prefix, prefix_size,
695
- NULL, 0,
696
- offset, limit, flags);
694
+ prefix, prefix_size,
695
+ NULL, 0,
696
+ offset, limit, flags);
697
697
  rb_grn_context_check(*context, self);
698
698
 
699
699
  return cursor;
@@ -741,19 +741,19 @@ rb_grn_patricia_trie_open_rk_cursor (int argc, VALUE *argv, VALUE self)
741
741
  VALUE rb_cursor;
742
742
 
743
743
  cursor = rb_grn_patricia_trie_open_grn_rk_cursor(argc, argv,
744
- self, &context);
744
+ self, &context);
745
745
  rb_cursor = GRNTABLECURSOR2RVAL(Qnil, context, cursor);
746
746
  rb_iv_set(rb_cursor, "@table", self); /* FIXME: cursor should mark table */
747
747
  if (rb_block_given_p())
748
- return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
748
+ return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
749
749
  else
750
- return rb_cursor;
750
+ return rb_cursor;
751
751
  }
752
752
 
753
753
 
754
754
  static grn_table_cursor *
755
755
  rb_grn_patricia_trie_open_grn_near_cursor (int argc, VALUE *argv, VALUE self,
756
- grn_ctx **context, int flags)
756
+ grn_ctx **context, int flags)
757
757
  {
758
758
  grn_obj *table;
759
759
  grn_obj *key_p = NULL, casted_key;
@@ -766,46 +766,46 @@ rb_grn_patricia_trie_open_grn_near_cursor (int argc, VALUE *argv, VALUE self,
766
766
  flags |= GRN_CURSOR_PREFIX;
767
767
 
768
768
  rb_grn_table_deconstruct((RbGrnTable *)SELF(self), &table, context,
769
- NULL, NULL,
770
- NULL, NULL, NULL,
771
- NULL);
769
+ NULL, NULL,
770
+ NULL, NULL, NULL,
771
+ NULL);
772
772
 
773
773
  rb_scan_args(argc, argv, "11", &rb_key, &options);
774
774
 
775
775
  rb_grn_scan_options(options,
776
- "size", &rb_min_size,
776
+ "size", &rb_min_size,
777
777
  "offset", &rb_offset,
778
778
  "limit", &rb_limit,
779
- "greater_than", &rb_greater_than,
780
- "less_than", &rb_less_than,
781
- NULL);
779
+ "greater_than", &rb_greater_than,
780
+ "less_than", &rb_less_than,
781
+ NULL);
782
782
 
783
783
  key_p = RVAL2GRNBULK_WITH_TYPE(rb_key, *context, key_p,
784
- table->header.domain,
785
- grn_ctx_at(*context, table->header.domain));
784
+ table->header.domain,
785
+ grn_ctx_at(*context, table->header.domain));
786
786
  GRN_OBJ_INIT(&casted_key, GRN_BULK, 0, table->header.domain);
787
787
  if (key_p->header.domain != table->header.domain) {
788
- grn_obj_cast(*context, key_p, &casted_key, GRN_FALSE);
789
- grn_obj_unlink(*context, key_p);
790
- key_p = &casted_key;
788
+ grn_obj_cast(*context, key_p, &casted_key, GRN_FALSE);
789
+ grn_obj_unlink(*context, key_p);
790
+ key_p = &casted_key;
791
791
  }
792
792
 
793
793
  if (!NIL_P(rb_min_size))
794
- min_size = NUM2UINT(rb_min_size);
794
+ min_size = NUM2UINT(rb_min_size);
795
795
  if (!NIL_P(rb_offset))
796
- offset = NUM2INT(rb_offset);
796
+ offset = NUM2INT(rb_offset);
797
797
  if (!NIL_P(rb_limit))
798
- limit = NUM2INT(rb_limit);
798
+ limit = NUM2INT(rb_limit);
799
799
 
800
800
  if (RVAL2CBOOL(rb_greater_than))
801
- flags |= GRN_CURSOR_GT;
801
+ flags |= GRN_CURSOR_GT;
802
802
  if (RVAL2CBOOL(rb_less_than))
803
- flags |= GRN_CURSOR_LT;
803
+ flags |= GRN_CURSOR_LT;
804
804
 
805
805
  cursor = grn_table_cursor_open(*context, table,
806
- NULL, min_size,
807
- GRN_BULK_HEAD(key_p), GRN_BULK_VSIZE(key_p),
808
- offset, limit, flags);
806
+ NULL, min_size,
807
+ GRN_BULK_HEAD(key_p), GRN_BULK_VSIZE(key_p),
808
+ offset, limit, flags);
809
809
  GRN_OBJ_FIN(*context, &casted_key);
810
810
  rb_grn_context_check(*context, self);
811
811
 
@@ -850,42 +850,42 @@ rb_grn_patricia_trie_open_near_cursor (int argc, VALUE *argv, VALUE self)
850
850
  VALUE rb_cursor;
851
851
 
852
852
  cursor = rb_grn_patricia_trie_open_grn_near_cursor(argc, argv,
853
- self, &context, GRN_CURSOR_RK);
853
+ self, &context, GRN_CURSOR_RK);
854
854
  rb_cursor = GRNTABLECURSOR2RVAL(Qnil, context, cursor);
855
855
  rb_iv_set(rb_cursor, "@table", self); /* FIXME: cursor should mark table */
856
856
  if (rb_block_given_p())
857
- return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
857
+ return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
858
858
  else
859
- return rb_cursor;
859
+ return rb_cursor;
860
860
  }
861
861
 
862
862
  void
863
863
  rb_grn_init_patricia_trie (VALUE mGrn)
864
864
  {
865
865
  rb_cGrnPatriciaTrie =
866
- rb_define_class_under(mGrn, "PatriciaTrie", rb_cGrnTable);
866
+ rb_define_class_under(mGrn, "PatriciaTrie", rb_cGrnTable);
867
867
 
868
868
  rb_include_module(rb_cGrnPatriciaTrie, rb_mGrnTableKeySupport);
869
869
  rb_define_singleton_method(rb_cGrnPatriciaTrie, "create",
870
- rb_grn_patricia_trie_s_create, -1);
870
+ rb_grn_patricia_trie_s_create, -1);
871
871
 
872
872
  rb_define_method(rb_cGrnPatriciaTrie, "search",
873
- rb_grn_patricia_trie_search, -1);
873
+ rb_grn_patricia_trie_search, -1);
874
874
  rb_define_method(rb_cGrnPatriciaTrie, "scan",
875
- rb_grn_patricia_trie_scan, 1);
875
+ rb_grn_patricia_trie_scan, 1);
876
876
  rb_define_method(rb_cGrnPatriciaTrie, "prefix_search",
877
- rb_grn_patricia_trie_prefix_search, 1);
877
+ rb_grn_patricia_trie_prefix_search, 1);
878
878
 
879
879
  rb_define_method(rb_cGrnPatriciaTrie, "register_key_with_sis?",
880
- rb_grn_patricia_trie_register_key_with_sis_p, 0);
880
+ rb_grn_patricia_trie_register_key_with_sis_p, 0);
881
881
 
882
882
  rb_define_method(rb_cGrnPatriciaTrie, "open_prefix_cursor",
883
- rb_grn_patricia_trie_open_prefix_cursor,
884
- -1);
883
+ rb_grn_patricia_trie_open_prefix_cursor,
884
+ -1);
885
885
  rb_define_method(rb_cGrnPatriciaTrie, "open_rk_cursor",
886
- rb_grn_patricia_trie_open_rk_cursor,
887
- -1);
886
+ rb_grn_patricia_trie_open_rk_cursor,
887
+ -1);
888
888
  rb_define_method(rb_cGrnPatriciaTrie, "open_near_cursor",
889
- rb_grn_patricia_trie_open_near_cursor,
890
- -1);
889
+ rb_grn_patricia_trie_open_near_cursor,
890
+ -1);
891
891
  }
@@ -36,12 +36,12 @@ rb_grn_plugin_from_ruby_object (VALUE object)
36
36
  RbGrnPlugin *rb_grn_plugin;
37
37
 
38
38
  if (!RVAL2CBOOL(rb_obj_is_kind_of(object, cGrnPlugin))) {
39
- rb_raise(rb_eTypeError, "not a groonga plugin");
39
+ rb_raise(rb_eTypeError, "not a groonga plugin");
40
40
  }
41
41
 
42
42
  Data_Get_Struct(object, RbGrnPlugin, rb_grn_plugin);
43
43
  if (!rb_grn_plugin)
44
- rb_raise(rb_eGrnError, "groonga plugin is NULL");
44
+ rb_raise(rb_eGrnError, "groonga plugin is NULL");
45
45
  return rb_grn_plugin->id;
46
46
  }
47
47
 
@@ -152,9 +152,9 @@ rb_grn_init_plugin (VALUE mGrn)
152
152
  rb_define_alloc_func(cGrnPlugin, rb_grn_plugin_alloc);
153
153
 
154
154
  rb_define_singleton_method(cGrnPlugin, "register",
155
- rb_grn_plugin_s_register, -1);
155
+ rb_grn_plugin_s_register, -1);
156
156
  rb_define_singleton_method(cGrnPlugin, "system_plugins_dir",
157
- rb_grn_plugin_s_system_plugins_dir, 0);
157
+ rb_grn_plugin_s_system_plugins_dir, 0);
158
158
  rb_define_singleton_method(cGrnPlugin, "suffix",
159
- rb_grn_plugin_s_suffix, 0);
159
+ rb_grn_plugin_s_suffix, 0);
160
160
  }