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
@@ -53,7 +53,7 @@ grn_obj *
53
53
  rb_grn_column_from_ruby_object (VALUE object, grn_ctx **context)
54
54
  {
55
55
  if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnColumn))) {
56
- rb_raise(rb_eTypeError, "not a groonga column");
56
+ rb_raise(rb_eTypeError, "not a groonga column");
57
57
  }
58
58
 
59
59
  return RVAL2GRNOBJECT(object, context);
@@ -61,14 +61,14 @@ rb_grn_column_from_ruby_object (VALUE object, grn_ctx **context)
61
61
 
62
62
  VALUE
63
63
  rb_grn_column_to_ruby_object (VALUE klass, grn_ctx *context, grn_obj *column,
64
- grn_bool owner)
64
+ grn_bool owner)
65
65
  {
66
66
  return GRNOBJECT2RVAL(klass, context, column, owner);
67
67
  }
68
68
 
69
69
  void
70
70
  rb_grn_column_bind (RbGrnColumn *rb_column,
71
- grn_ctx *context, grn_obj *column)
71
+ grn_ctx *context, grn_obj *column)
72
72
  {
73
73
  RbGrnObject *rb_grn_object;
74
74
 
@@ -80,34 +80,34 @@ rb_grn_column_bind (RbGrnColumn *rb_column,
80
80
 
81
81
  void
82
82
  rb_grn_column_finalizer (grn_ctx *context, grn_obj *grn_object,
83
- RbGrnColumn *rb_column)
83
+ RbGrnColumn *rb_column)
84
84
  {
85
85
  rb_grn_named_object_finalizer(context, grn_object,
86
- RB_GRN_NAMED_OBJECT(rb_column));
86
+ RB_GRN_NAMED_OBJECT(rb_column));
87
87
  if (context && rb_column->value)
88
- grn_obj_unlink(context, rb_column->value);
88
+ grn_obj_unlink(context, rb_column->value);
89
89
  rb_column->value = NULL;
90
90
  }
91
91
 
92
92
  void
93
93
  rb_grn_column_deconstruct (RbGrnColumn *rb_column,
94
- grn_obj **column,
95
- grn_ctx **context,
96
- grn_id *domain_id,
97
- grn_obj **domain,
98
- grn_obj **value,
99
- grn_id *range_id,
100
- grn_obj **range)
94
+ grn_obj **column,
95
+ grn_ctx **context,
96
+ grn_id *domain_id,
97
+ grn_obj **domain,
98
+ grn_obj **value,
99
+ grn_id *range_id,
100
+ grn_obj **range)
101
101
  {
102
102
  RbGrnObject *rb_grn_object;
103
103
 
104
104
  rb_grn_object = RB_GRN_OBJECT(rb_column);
105
105
  rb_grn_object_deconstruct(rb_grn_object, column, context,
106
- domain_id, domain,
107
- range_id, range);
106
+ domain_id, domain,
107
+ range_id, range);
108
108
 
109
109
  if (value)
110
- *value = rb_column->value;
110
+ *value = rb_column->value;
111
111
  }
112
112
 
113
113
  /*
@@ -124,8 +124,8 @@ rb_grn_column_get_table (VALUE self)
124
124
  grn_obj *table;
125
125
 
126
126
  rb_grn_object_deconstruct((RbGrnObject *)(SELF(self)), &column, &context,
127
- NULL, NULL,
128
- NULL, NULL);
127
+ NULL, NULL,
128
+ NULL, NULL);
129
129
  table = grn_column_table(context, column);
130
130
  rb_grn_context_check(context, self);
131
131
 
@@ -154,11 +154,11 @@ rb_grn_column_get_local_name (VALUE self)
154
154
 
155
155
  rb_grn_column = SELF(self);
156
156
  rb_grn_object_deconstruct(RB_GRN_OBJECT(rb_grn_column), &column, &context,
157
- NULL, NULL,
158
- NULL, NULL);
157
+ NULL, NULL,
158
+ NULL, NULL);
159
159
  name_size = grn_column_name(context, column, NULL, 0);
160
160
  if (name_size == 0)
161
- return Qnil;
161
+ return Qnil;
162
162
 
163
163
  name = xmalloc(name_size);
164
164
  grn_column_name(context, column, name, name_size);
@@ -317,8 +317,8 @@ rb_grn_column_select (int argc, VALUE *argv, VALUE self)
317
317
  rb_scan_args(argc, argv, "02", &condition_or_options, &options);
318
318
 
319
319
  rb_grn_column_deconstruct(SELF(self), &column, &context,
320
- NULL, NULL,
321
- NULL, NULL, NULL);
320
+ NULL, NULL,
321
+ NULL, NULL, NULL);
322
322
  table = grn_column_table(context, column);
323
323
 
324
324
  if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options, rb_cString))) {
@@ -329,35 +329,35 @@ rb_grn_column_select (int argc, VALUE *argv, VALUE self)
329
329
  } else {
330
330
  if (!NIL_P(options))
331
331
  rb_raise(rb_eArgError,
332
- "should be [query_string, option_hash], "
333
- "[expression, option_hash] "
334
- "or [option_hash]: %s",
335
- rb_grn_inspect(rb_ary_new4(argc, argv)));
332
+ "should be [query_string, option_hash], "
333
+ "[expression, option_hash] "
334
+ "or [option_hash]: %s",
335
+ rb_grn_inspect(rb_ary_new4(argc, argv)));
336
336
  options = condition_or_options;
337
337
  }
338
338
 
339
339
  rb_grn_scan_options(options,
340
- "operator", &rb_operator,
341
- "result", &rb_result,
342
- "name", &rb_name,
343
- "syntax", &rb_syntax,
344
- "allow_pragma", &rb_allow_pragma,
345
- "allow_column", &rb_allow_column,
346
- "allow_update", &rb_allow_update,
347
- "allow_leading_not", &rb_allow_leading_not,
348
- NULL);
340
+ "operator", &rb_operator,
341
+ "result", &rb_result,
342
+ "name", &rb_name,
343
+ "syntax", &rb_syntax,
344
+ "allow_pragma", &rb_allow_pragma,
345
+ "allow_column", &rb_allow_column,
346
+ "allow_update", &rb_allow_update,
347
+ "allow_leading_not", &rb_allow_leading_not,
348
+ NULL);
349
349
 
350
350
  if (!NIL_P(rb_operator))
351
- operator = NUM2INT(rb_operator);
351
+ operator = NUM2INT(rb_operator);
352
352
 
353
353
  if (NIL_P(rb_result)) {
354
- result = grn_table_create(context, NULL, 0, NULL,
355
- GRN_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
356
- table,
357
- 0);
358
- rb_result = GRNTABLE2RVAL(context, result, GRN_TRUE);
354
+ result = grn_table_create(context, NULL, 0, NULL,
355
+ GRN_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
356
+ table,
357
+ 0);
358
+ rb_result = GRNTABLE2RVAL(context, result, GRN_TRUE);
359
359
  } else {
360
- result = RVAL2GRNTABLE(rb_result, &context);
360
+ result = RVAL2GRNTABLE(rb_result, &context);
361
361
  }
362
362
 
363
363
  if (NIL_P(rb_expression)) {
@@ -377,8 +377,8 @@ rb_grn_column_select (int argc, VALUE *argv, VALUE self)
377
377
  rb_grn_context_check(context, self);
378
378
 
379
379
  rb_attr(rb_singleton_class(rb_result),
380
- rb_intern("expression"),
381
- GRN_TRUE, GRN_FALSE, GRN_FALSE);
380
+ rb_intern("expression"),
381
+ GRN_TRUE, GRN_FALSE, GRN_FALSE);
382
382
  rb_iv_set(rb_result, "@expression", rb_expression);
383
383
 
384
384
  return rb_result;
@@ -404,15 +404,15 @@ rb_grn_column_unlock (int argc, VALUE *argv, VALUE self)
404
404
  rb_scan_args(argc, argv, "01", &options);
405
405
 
406
406
  rb_grn_column_deconstruct(SELF(self), &column, &context,
407
- NULL, NULL,
408
- NULL, NULL, NULL);
407
+ NULL, NULL,
408
+ NULL, NULL, NULL);
409
409
 
410
410
  rb_grn_scan_options(options,
411
- "id", &rb_id,
412
- NULL);
411
+ "id", &rb_id,
412
+ NULL);
413
413
 
414
414
  if (!NIL_P(rb_id))
415
- id = NUM2UINT(rb_id);
415
+ id = NUM2UINT(rb_id);
416
416
 
417
417
  rc = grn_obj_unlock(context, column, id);
418
418
  rb_grn_context_check(context, self);
@@ -459,28 +459,28 @@ rb_grn_column_lock (int argc, VALUE *argv, VALUE self)
459
459
  rb_scan_args(argc, argv, "01", &options);
460
460
 
461
461
  rb_grn_column_deconstruct(SELF(self), &column, &context,
462
- NULL, NULL,
463
- NULL, NULL, NULL);
462
+ NULL, NULL,
463
+ NULL, NULL, NULL);
464
464
 
465
465
  rb_grn_scan_options(options,
466
- "timeout", &rb_timeout,
467
- "id", &rb_id,
468
- NULL);
466
+ "timeout", &rb_timeout,
467
+ "id", &rb_id,
468
+ NULL);
469
469
 
470
470
  if (!NIL_P(rb_timeout))
471
- timeout = NUM2UINT(rb_timeout);
471
+ timeout = NUM2UINT(rb_timeout);
472
472
 
473
473
  if (!NIL_P(rb_id))
474
- id = NUM2UINT(rb_id);
474
+ id = NUM2UINT(rb_id);
475
475
 
476
476
  rc = grn_obj_lock(context, column, id, timeout);
477
477
  rb_grn_context_check(context, self);
478
478
  rb_grn_rc_check(rc, self);
479
479
 
480
480
  if (rb_block_given_p()) {
481
- return rb_ensure(rb_yield, Qnil, rb_grn_column_unlock_ensure, self);
481
+ return rb_ensure(rb_yield, Qnil, rb_grn_column_unlock_ensure, self);
482
482
  } else {
483
- return Qnil;
483
+ return Qnil;
484
484
  }
485
485
  }
486
486
 
@@ -505,15 +505,15 @@ rb_grn_column_clear_lock (int argc, VALUE *argv, VALUE self)
505
505
  rb_scan_args(argc, argv, "01", &options);
506
506
 
507
507
  rb_grn_column_deconstruct(SELF(self), &column, &context,
508
- NULL, NULL,
509
- NULL, NULL, NULL);
508
+ NULL, NULL,
509
+ NULL, NULL, NULL);
510
510
 
511
511
  rb_grn_scan_options(options,
512
- "id", &rb_id,
513
- NULL);
512
+ "id", &rb_id,
513
+ NULL);
514
514
 
515
515
  if (!NIL_P(rb_id))
516
- id = NUM2UINT(rb_id);
516
+ id = NUM2UINT(rb_id);
517
517
 
518
518
  grn_obj_clear_lock(context, column);
519
519
 
@@ -541,15 +541,15 @@ rb_grn_column_is_locked (int argc, VALUE *argv, VALUE self)
541
541
  rb_scan_args(argc, argv, "01", &options);
542
542
 
543
543
  rb_grn_column_deconstruct(SELF(self), &column, &context,
544
- NULL, NULL,
545
- NULL, NULL, NULL);
544
+ NULL, NULL,
545
+ NULL, NULL, NULL);
546
546
 
547
547
  rb_grn_scan_options(options,
548
- "id", &rb_id,
549
- NULL);
548
+ "id", &rb_id,
549
+ NULL);
550
550
 
551
551
  if (!NIL_P(rb_id))
552
- id = NUM2UINT(rb_id);
552
+ id = NUM2UINT(rb_id);
553
553
 
554
554
  return CBOOL2RVAL(grn_obj_is_locked(context, column));
555
555
  }
@@ -572,8 +572,8 @@ rb_grn_column_reference_p (VALUE self)
572
572
  unsigned short int type;
573
573
 
574
574
  rb_grn_column_deconstruct(SELF(self), &column, &context,
575
- NULL, NULL,
576
- NULL, NULL, NULL);
575
+ NULL, NULL,
576
+ NULL, NULL, NULL);
577
577
 
578
578
  range_id = grn_obj_get_range(context, column);
579
579
  range = grn_ctx_at(context, range_id);
@@ -583,9 +583,9 @@ rb_grn_column_reference_p (VALUE self)
583
583
  case GRN_TABLE_HASH_KEY:
584
584
  case GRN_TABLE_PAT_KEY:
585
585
  case GRN_TABLE_NO_KEY:
586
- return Qtrue;
586
+ return Qtrue;
587
587
  default:
588
- return Qfalse;
588
+ return Qfalse;
589
589
  }
590
590
  }
591
591
 
@@ -604,13 +604,13 @@ rb_grn_column_index_p (VALUE self)
604
604
  grn_obj *column;
605
605
 
606
606
  rb_grn_column_deconstruct(SELF(self), &column, &context,
607
- NULL, NULL,
608
- NULL, NULL, NULL);
607
+ NULL, NULL,
608
+ NULL, NULL, NULL);
609
609
 
610
610
  if (column->header.type == GRN_COLUMN_INDEX) {
611
- return Qtrue;
611
+ return Qtrue;
612
612
  } else {
613
- return Qfalse;
613
+ return Qfalse;
614
614
  }
615
615
  }
616
616
 
@@ -629,15 +629,15 @@ rb_grn_column_vector_p (VALUE self)
629
629
  grn_obj *column;
630
630
 
631
631
  rb_grn_column_deconstruct(SELF(self), &column, &context,
632
- NULL, NULL,
633
- NULL, NULL, NULL);
632
+ NULL, NULL,
633
+ NULL, NULL, NULL);
634
634
 
635
635
  if (column->header.type == GRN_COLUMN_VAR_SIZE &&
636
- ((column->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) ==
637
- GRN_OBJ_COLUMN_VECTOR)) {
638
- return Qtrue;
636
+ ((column->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) ==
637
+ GRN_OBJ_COLUMN_VECTOR)) {
638
+ return Qtrue;
639
639
  } else {
640
- return Qfalse;
640
+ return Qfalse;
641
641
  }
642
642
  }
643
643
 
@@ -656,21 +656,21 @@ rb_grn_column_scalar_p (VALUE self)
656
656
  grn_obj *column;
657
657
 
658
658
  rb_grn_column_deconstruct(SELF(self), &column, &context,
659
- NULL, NULL,
660
- NULL, NULL, NULL);
659
+ NULL, NULL,
660
+ NULL, NULL, NULL);
661
661
 
662
662
  switch (column->header.type) {
663
663
  case GRN_COLUMN_FIX_SIZE:
664
- return Qtrue;
664
+ return Qtrue;
665
665
  case GRN_COLUMN_VAR_SIZE:
666
- if ((column->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) ==
667
- GRN_OBJ_COLUMN_SCALAR) {
668
- return Qtrue;
669
- } else {
670
- return Qfalse;
671
- }
666
+ if ((column->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) ==
667
+ GRN_OBJ_COLUMN_SCALAR) {
668
+ return Qtrue;
669
+ } else {
670
+ return Qfalse;
671
+ }
672
672
  default:
673
- return Qfalse;
673
+ return Qfalse;
674
674
  }
675
675
  }
676
676
 
@@ -694,27 +694,27 @@ rb_grn_column_get_indexes (int argc, VALUE *argv, VALUE self)
694
694
  rb_scan_args(argc, argv, "01", &rb_operator);
695
695
 
696
696
  rb_grn_column_deconstruct(SELF(self), &column, &context,
697
- NULL, NULL,
698
- NULL, NULL, NULL);
697
+ NULL, NULL,
698
+ NULL, NULL, NULL);
699
699
 
700
700
  if (!NIL_P(rb_operator)) {
701
- operator = RVAL2GRNOPERATOR(rb_operator);
701
+ operator = RVAL2GRNOPERATOR(rb_operator);
702
702
  }
703
703
 
704
704
  rb_indexes = rb_ary_new();
705
705
  n_indexes = grn_column_index(context, column, operator,
706
- NULL, 0, NULL);
706
+ NULL, 0, NULL);
707
707
  if (n_indexes == 0)
708
- return rb_indexes;
708
+ return rb_indexes;
709
709
 
710
710
  indexes = xmalloc(sizeof(grn_obj *) * n_indexes);
711
711
  n_indexes = grn_column_index(context, column, operator,
712
- indexes, n_indexes, NULL);
712
+ indexes, n_indexes, NULL);
713
713
  for (i = 0; i < n_indexes; i++) {
714
- VALUE rb_index;
715
- rb_index = GRNOBJECT2RVAL(Qnil, context, indexes[i], GRN_FALSE);
716
- rb_ary_push(rb_indexes, rb_index);
717
- grn_obj_unlink(context, indexes[i]);
714
+ VALUE rb_index;
715
+ rb_index = GRNOBJECT2RVAL(Qnil, context, indexes[i], GRN_FALSE);
716
+ rb_ary_push(rb_indexes, rb_index);
717
+ grn_obj_unlink(context, indexes[i]);
718
718
  }
719
719
  xfree(indexes);
720
720
  return rb_indexes;
@@ -736,8 +736,8 @@ rb_grn_column_rename (VALUE self, VALUE rb_name)
736
736
  int name_size;
737
737
 
738
738
  rb_grn_column_deconstruct(SELF(self), &column, &context,
739
- NULL, NULL,
740
- NULL, NULL, NULL);
739
+ NULL, NULL,
740
+ NULL, NULL, NULL);
741
741
 
742
742
  name = StringValueCStr(rb_name);
743
743
  name_size = RSTRING_LEN(rb_name);
@@ -756,7 +756,7 @@ rb_grn_init_column (VALUE mGrn)
756
756
 
757
757
  rb_define_method(rb_cGrnColumn, "table", rb_grn_column_get_table, 0);
758
758
  rb_define_method(rb_cGrnColumn, "local_name",
759
- rb_grn_column_get_local_name, 0);
759
+ rb_grn_column_get_local_name, 0);
760
760
 
761
761
  rb_define_method(rb_cGrnColumn, "select", rb_grn_column_select, -1);
762
762
  rb_define_method(rb_cGrnColumn, "lock", rb_grn_column_lock, -1);