rroonga 3.0.5-x86-mingw32 → 3.0.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/AUTHORS +5 -0
  2. data/Gemfile +20 -0
  3. data/Rakefile +187 -0
  4. data/doc/text/news.textile +7 -0
  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/lib/1.9/groonga.so +0 -0
  42. data/lib/2.0/groonga.so +0 -0
  43. data/rroonga-build.rb +7 -0
  44. data/rroonga.gemspec +1 -1
  45. data/test/test-hash.rb +4 -4
  46. data/test/test-index-column.rb +271 -257
  47. data/test/test-table-key-support.rb +78 -0
  48. data/test/test-table.rb +78 -51
  49. metadata +8 -3
@@ -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);
@@ -49,15 +49,15 @@ rb_grn_context_from_ruby_object (VALUE object)
49
49
  RbGrnContext *rb_grn_context;
50
50
 
51
51
  if (!RVAL2CBOOL(rb_obj_is_kind_of(object, cGrnContext))) {
52
- rb_raise(rb_eTypeError, "not a groonga context");
52
+ rb_raise(rb_eTypeError, "not a groonga context");
53
53
  }
54
54
 
55
55
  Data_Get_Struct(object, RbGrnContext, rb_grn_context);
56
56
  if (!rb_grn_context)
57
- rb_raise(rb_eGrnError, "groonga context is NULL");
57
+ rb_raise(rb_eGrnError, "groonga context is NULL");
58
58
  if (!rb_grn_context->context)
59
- rb_raise(rb_eGrnClosed,
60
- "can't access already closed groonga context");
59
+ rb_raise(rb_eGrnClosed,
60
+ "can't access already closed groonga context");
61
61
  return rb_grn_context->context;
62
62
  }
63
63
 
@@ -72,12 +72,12 @@ rb_grn_context_register_floating_object (RbGrnObject *rb_grn_object)
72
72
  context = rb_grn_context->context;
73
73
  floating_objects = rb_grn_context->floating_objects;
74
74
  if (!floating_objects) {
75
- rb_grn_context_reset_floating_objects(rb_grn_context);
76
- floating_objects = rb_grn_context->floating_objects;
75
+ rb_grn_context_reset_floating_objects(rb_grn_context);
76
+ floating_objects = rb_grn_context->floating_objects;
77
77
  }
78
78
  grn_hash_add(context, floating_objects,
79
- (const void *)(&rb_grn_object), sizeof(RbGrnObject *),
80
- NULL, NULL);
79
+ (const void *)(&rb_grn_object), sizeof(RbGrnObject *),
80
+ NULL, NULL);
81
81
  rb_grn_object->floating = GRN_TRUE;
82
82
  }
83
83
 
@@ -89,17 +89,17 @@ rb_grn_context_unregister_floating_object (RbGrnObject *rb_grn_object)
89
89
  grn_hash *floating_objects;
90
90
 
91
91
  if (!rb_grn_object->floating)
92
- return;
92
+ return;
93
93
 
94
94
  rb_grn_context = rb_grn_object->rb_grn_context;
95
95
  if (!rb_grn_context)
96
- return;
96
+ return;
97
97
 
98
98
  context = rb_grn_context->context;
99
99
  floating_objects = rb_grn_context->floating_objects;
100
100
  grn_hash_delete(context, floating_objects,
101
- (const void *)&rb_grn_object, sizeof(RbGrnObject *),
102
- NULL);
101
+ (const void *)&rb_grn_object, sizeof(RbGrnObject *),
102
+ NULL);
103
103
  rb_grn_object->floating = GRN_FALSE;
104
104
  }
105
105
 
@@ -113,13 +113,13 @@ rb_grn_context_close_floating_objects (RbGrnContext *rb_grn_context)
113
113
  context = rb_grn_context->context;
114
114
  floating_objects = rb_grn_context->floating_objects;
115
115
  if (!floating_objects)
116
- return;
116
+ return;
117
117
 
118
118
  rb_grn_context->floating_objects = NULL;
119
119
  GRN_HASH_EACH(context, floating_objects, id, &floating_object, NULL, NULL, {
120
- (*floating_object)->floating = GRN_FALSE;
121
- grn_obj_close(context, RB_GRN_OBJECT(*floating_object)->object);
122
- });
120
+ (*floating_object)->floating = GRN_FALSE;
121
+ grn_obj_close(context, RB_GRN_OBJECT(*floating_object)->object);
122
+ });
123
123
  grn_hash_close(context, floating_objects);
124
124
  }
125
125
 
@@ -131,9 +131,9 @@ rb_grn_context_reset_floating_objects (RbGrnContext *rb_grn_context)
131
131
  rb_grn_context_close_floating_objects(rb_grn_context);
132
132
  context = rb_grn_context->context;
133
133
  rb_grn_context->floating_objects = grn_hash_create(context, NULL,
134
- sizeof(RbGrnObject *),
135
- 0,
136
- GRN_OBJ_TABLE_HASH_KEY);
134
+ sizeof(RbGrnObject *),
135
+ 0,
136
+ GRN_OBJ_TABLE_HASH_KEY);
137
137
  }
138
138
 
139
139
  void
@@ -145,15 +145,15 @@ rb_grn_context_mark_grn_id (grn_ctx *context, grn_id id)
145
145
 
146
146
  object = grn_ctx_at(context, id);
147
147
  if (!object)
148
- return;
148
+ return;
149
149
 
150
150
  user_data = grn_obj_user_data(context, object);
151
151
  if (!user_data)
152
- return;
152
+ return;
153
153
 
154
154
  rb_grn_object = RB_GRN_OBJECT(user_data->ptr);
155
155
  if (!rb_grn_object)
156
- return;
156
+ return;
157
157
 
158
158
  rb_gc_mark(rb_grn_object->self);
159
159
  }
@@ -176,10 +176,10 @@ static void
176
176
  rb_grn_context_fin (grn_ctx *context)
177
177
  {
178
178
  if (context->stat == GRN_CTX_FIN)
179
- return;
179
+ return;
180
180
 
181
181
  if (!(context->flags & GRN_CTX_PER_DB)) {
182
- rb_grn_context_unlink_database(context);
182
+ rb_grn_context_unlink_database(context);
183
183
  }
184
184
  grn_ctx_fin(context);
185
185
  }
@@ -194,7 +194,7 @@ rb_grn_context_free (void *pointer)
194
194
  debug("context-free: %p\n", context);
195
195
  rb_grn_context_close_floating_objects(rb_grn_context);
196
196
  if (context && !rb_grn_exited)
197
- rb_grn_context_fin(context);
197
+ rb_grn_context_fin(context);
198
198
  debug("context-free: %p: done\n", context);
199
199
  xfree(rb_grn_context);
200
200
  }
@@ -207,30 +207,30 @@ rb_grn_context_alloc (VALUE klass)
207
207
 
208
208
  static grn_obj *
209
209
  rb_grn_context_finalizer (grn_ctx *context, int n_args, grn_obj **grn_objects,
210
- grn_user_data *user_data)
210
+ grn_user_data *user_data)
211
211
  {
212
212
  RbGrnContext *rb_grn_context;
213
213
 
214
214
  if (rb_grn_exited)
215
- return NULL;
215
+ return NULL;
216
216
 
217
217
  rb_grn_context = user_data->ptr;
218
218
 
219
219
  rb_grn_context_close_floating_objects(rb_grn_context);
220
220
  if (!(context->flags & GRN_CTX_PER_DB)) {
221
- rb_grn_context_unlink_database(context);
221
+ rb_grn_context_unlink_database(context);
222
222
  }
223
223
 
224
224
  GRN_CTX_USER_DATA(context)->ptr = NULL;
225
225
  grn_ctx_set_finalizer(context, NULL);
226
226
 
227
227
  debug("context-finalize: %p:%p:%p\n",
228
- context, rb_grn_context, rb_grn_context->context);
228
+ context, rb_grn_context, rb_grn_context->context);
229
229
 
230
230
  rb_grn_context->context = NULL;
231
231
 
232
232
  debug("context-finalize: %p:%p:%p: done\n",
233
- context, rb_grn_context, rb_grn_context->context);
233
+ context, rb_grn_context, rb_grn_context->context);
234
234
 
235
235
  return NULL;
236
236
  }
@@ -243,7 +243,7 @@ rb_grn_context_to_exception (grn_ctx *context, VALUE related_object)
243
243
  grn_obj bulk;
244
244
 
245
245
  if (context->rc == GRN_SUCCESS)
246
- return Qnil;
246
+ return Qnil;
247
247
 
248
248
  exception_class = rb_grn_rc_to_exception(context->rc);
249
249
  message = rb_grn_rc_to_message(context->rc);
@@ -255,8 +255,8 @@ rb_grn_context_to_exception (grn_ctx *context, VALUE related_object)
255
255
  GRN_TEXT_PUTS(context, &bulk, context->errbuf);
256
256
  }
257
257
  if (!NIL_P(related_object)) {
258
- GRN_TEXT_PUTS(context, &bulk, ": ");
259
- GRN_TEXT_PUTS(context, &bulk, rb_grn_inspect(related_object));
258
+ GRN_TEXT_PUTS(context, &bulk, ": ");
259
+ GRN_TEXT_PUTS(context, &bulk, rb_grn_inspect(related_object));
260
260
  }
261
261
  if (context->errline > 0) {
262
262
  GRN_TEXT_PUTS(context, &bulk, "\n");
@@ -268,8 +268,8 @@ rb_grn_context_to_exception (grn_ctx *context, VALUE related_object)
268
268
  GRN_TEXT_PUTS(context, &bulk, "()");
269
269
  }
270
270
  exception = rb_funcall(exception_class, rb_intern("new"), 1,
271
- rb_str_new(GRN_BULK_HEAD(&bulk),
272
- GRN_BULK_VSIZE(&bulk)));
271
+ rb_str_new(GRN_BULK_HEAD(&bulk),
272
+ GRN_BULK_VSIZE(&bulk)));
273
273
  grn_obj_unlink(context, &bulk);
274
274
 
275
275
  return exception;
@@ -282,7 +282,7 @@ rb_grn_context_check (grn_ctx *context, VALUE related_object)
282
282
 
283
283
  exception = rb_grn_context_to_exception(context, related_object);
284
284
  if (NIL_P(exception))
285
- return;
285
+ return;
286
286
 
287
287
  rb_exc_raise(exception);
288
288
  }
@@ -291,7 +291,7 @@ grn_ctx *
291
291
  rb_grn_context_ensure (VALUE *context)
292
292
  {
293
293
  if (NIL_P(*context))
294
- *context = rb_grn_context_get_default();
294
+ *context = rb_grn_context_get_default();
295
295
  return SELF(*context);
296
296
  }
297
297
 
@@ -299,10 +299,10 @@ VALUE
299
299
  rb_grn_context_rb_string_new (grn_ctx *context, const char *string, long length)
300
300
  {
301
301
  if (length < 0)
302
- length = strlen(string);
302
+ length = strlen(string);
303
303
  #ifdef HAVE_RUBY_ENCODING_H
304
304
  return rb_enc_str_new(string, length,
305
- rb_grn_encoding_to_ruby_encoding(context->encoding));
305
+ rb_grn_encoding_to_ruby_encoding(context->encoding));
306
306
  #else
307
307
  return rb_str_new(string, length);
308
308
  #endif
@@ -318,25 +318,25 @@ rb_grn_context_rb_string_encode (grn_ctx *context, VALUE rb_string)
318
318
 
319
319
  context_encoding = context->encoding;
320
320
  if (context->encoding == GRN_ENC_DEFAULT)
321
- context->encoding = grn_get_default_encoding();
321
+ context->encoding = grn_get_default_encoding();
322
322
  if (context->encoding == GRN_ENC_NONE)
323
- return rb_string;
323
+ return rb_string;
324
324
 
325
325
  if (RSTRING_LEN(rb_string) < 0)
326
- return rb_string;
326
+ return rb_string;
327
327
 
328
328
  encoding = rb_enc_get(rb_string);
329
329
  to_encoding = rb_grn_encoding_to_ruby_encoding(context_encoding);
330
330
  index = rb_enc_to_index(encoding);
331
331
  to_index = rb_enc_to_index(to_encoding);
332
332
  if (index == to_index)
333
- return rb_string;
333
+ return rb_string;
334
334
 
335
335
  if (rb_enc_asciicompat(to_encoding) && rb_enc_str_asciionly_p(rb_string))
336
- return rb_string;
336
+ return rb_string;
337
337
 
338
338
  rb_string = rb_str_encode(rb_string, rb_enc_from_encoding(to_encoding),
339
- 0, Qnil);
339
+ 0, Qnil);
340
340
  #endif
341
341
  return rb_string;
342
342
  }
@@ -366,8 +366,8 @@ rb_grn_context_s_get_default (VALUE self)
366
366
 
367
367
  context = rb_cv_get(self, "@@default");
368
368
  if (NIL_P(context)) {
369
- context = rb_funcall(cGrnContext, rb_intern("new"), 0);
370
- rb_cv_set(self, "@@default", context);
369
+ context = rb_funcall(cGrnContext, rb_intern("new"), 0);
370
+ rb_cv_set(self, "@@default", context);
371
371
  }
372
372
  return context;
373
373
  }
@@ -441,15 +441,15 @@ rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
441
441
  rb_scan_args(argc, argv, "01", &options);
442
442
  default_options = rb_grn_context_s_get_default_options(rb_obj_class(self));
443
443
  if (NIL_P(default_options))
444
- default_options = rb_hash_new();
444
+ default_options = rb_hash_new();
445
445
 
446
446
  if (NIL_P(options))
447
- options = rb_hash_new();
447
+ options = rb_hash_new();
448
448
  options = rb_funcall(default_options, rb_intern("merge"), 1, options);
449
449
 
450
450
  rb_grn_scan_options(options,
451
- "encoding", &rb_encoding,
452
- NULL);
451
+ "encoding", &rb_encoding,
452
+ NULL);
453
453
 
454
454
  rb_grn_context = ALLOC(RbGrnContext);
455
455
  DATA_PTR(self) = rb_grn_context;
@@ -464,10 +464,10 @@ rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
464
464
  grn_ctx_set_finalizer(context, rb_grn_context_finalizer);
465
465
 
466
466
  if (!NIL_P(rb_encoding)) {
467
- grn_encoding encoding;
467
+ grn_encoding encoding;
468
468
 
469
- encoding = RVAL2GRNENCODING(rb_encoding, NULL);
470
- GRN_CTX_SET_ENCODING(context, encoding);
469
+ encoding = RVAL2GRNENCODING(rb_encoding, NULL);
470
+ GRN_CTX_SET_ENCODING(context, encoding);
471
471
  }
472
472
 
473
473
  rb_iv_set(self, "@memory_pools", rb_ary_new());
@@ -492,10 +492,10 @@ rb_grn_context_close (VALUE self)
492
492
 
493
493
  context = SELF(self);
494
494
  if (context) {
495
- rc = grn_ctx_fin(context);
496
- Data_Get_Struct(self, RbGrnContext, rb_grn_context);
497
- rb_grn_context->context = NULL;
498
- rb_grn_rc_check(rc, self);
495
+ rc = grn_ctx_fin(context);
496
+ Data_Get_Struct(self, RbGrnContext, rb_grn_context);
497
+ rb_grn_context->context = NULL;
498
+ rb_grn_rc_check(rc, self);
499
499
  }
500
500
 
501
501
  return Qnil;
@@ -727,22 +727,22 @@ rb_grn_context_connect (int argc, VALUE *argv, VALUE self)
727
727
 
728
728
  rb_scan_args(argc, argv, "01", &options);
729
729
  rb_grn_scan_options(options,
730
- "host", &rb_host,
731
- "port", &rb_port,
732
- NULL);
730
+ "host", &rb_host,
731
+ "port", &rb_port,
732
+ NULL);
733
733
 
734
734
  context = SELF(self);
735
735
 
736
736
  if (NIL_P(rb_host)) {
737
- host = "localhost";
737
+ host = "localhost";
738
738
  } else {
739
- host = StringValueCStr(rb_host);
739
+ host = StringValueCStr(rb_host);
740
740
  }
741
741
 
742
742
  if (NIL_P(rb_port)) {
743
- port = 10041;
743
+ port = 10041;
744
744
  } else {
745
- port = NUM2INT(rb_port);
745
+ port = NUM2INT(rb_port);
746
746
  }
747
747
 
748
748
  rc = grn_ctx_connect(context, host, port, flags);
@@ -794,9 +794,9 @@ rb_grn_context_receive (VALUE self)
794
794
  context = SELF(self);
795
795
  query_id = grn_ctx_recv(context, &result, &result_size, &flags);
796
796
  if (result) {
797
- rb_result = rb_str_new(result, result_size);
797
+ rb_result = rb_str_new(result, result_size);
798
798
  } else {
799
- rb_result = Qnil;
799
+ rb_result = Qnil;
800
800
  }
801
801
  rb_grn_context_check(context, self);
802
802
 
@@ -809,38 +809,38 @@ grn_type_name_old_to_new (const char *name, unsigned int name_size)
809
809
  unsigned int i;
810
810
 
811
811
  for (i = 0; i < name_size; i++) {
812
- if (name[i] == '\0')
813
- return NULL;
812
+ if (name[i] == '\0')
813
+ return NULL;
814
814
  }
815
815
 
816
816
  if (strcmp(name, "<int>") == 0) {
817
- return "Int32";
817
+ return "Int32";
818
818
  } else if (strcmp(name, "<uint>") == 0) {
819
- return "UInt32";
819
+ return "UInt32";
820
820
  } else if (strcmp(name, "<int64>") == 0) {
821
- return "Int64";
821
+ return "Int64";
822
822
  } else if (strcmp(name, "<uint64>") == 0) {
823
- return "UInt64";
823
+ return "UInt64";
824
824
  } else if (strcmp(name, "<float>") == 0) {
825
- return "Float";
825
+ return "Float";
826
826
  } else if (strcmp(name, "<time>") == 0) {
827
- return "Time";
827
+ return "Time";
828
828
  } else if (strcmp(name, "<shorttext>") == 0) {
829
- return "ShortText";
829
+ return "ShortText";
830
830
  } else if (strcmp(name, "<text>") == 0) {
831
- return "Text";
831
+ return "Text";
832
832
  } else if (strcmp(name, "<longtext>") == 0) {
833
- return "LongText";
833
+ return "LongText";
834
834
  } else if (strcmp(name, "<token:delimit>") == 0) {
835
- return "TokenDelimit";
835
+ return "TokenDelimit";
836
836
  } else if (strcmp(name, "<token:unigram>") == 0) {
837
- return "TokenUnigram";
837
+ return "TokenUnigram";
838
838
  } else if (strcmp(name, "<token:bigram>") == 0) {
839
- return "TokenBigram";
839
+ return "TokenBigram";
840
840
  } else if (strcmp(name, "<token:trigram>") == 0) {
841
- return "TokenTrigram";
841
+ return "TokenTrigram";
842
842
  } else if (strcmp(name, "<token:mecab>") == 0) {
843
- return "TokenMecab";
843
+ return "TokenMecab";
844
844
  }
845
845
 
846
846
  return NULL;
@@ -848,26 +848,26 @@ grn_type_name_old_to_new (const char *name, unsigned int name_size)
848
848
 
849
849
  grn_obj *
850
850
  rb_grn_context_get_backward_compatibility (grn_ctx *context,
851
- const char *name,
852
- unsigned int name_size)
851
+ const char *name,
852
+ unsigned int name_size)
853
853
  {
854
854
  grn_obj *object;
855
855
 
856
856
  object = grn_ctx_get(context, name, name_size);
857
857
  if (!object) {
858
- const char *new_type_name;
858
+ const char *new_type_name;
859
859
 
860
- new_type_name = grn_type_name_old_to_new(name, name_size);
861
- if (new_type_name) {
862
- object = grn_ctx_get(context, new_type_name, strlen(new_type_name));
860
+ new_type_name = grn_type_name_old_to_new(name, name_size);
861
+ if (new_type_name) {
862
+ object = grn_ctx_get(context, new_type_name, strlen(new_type_name));
863
863
  #if 0
864
- if (object) {
865
- rb_warn("deprecated old data type name <%s> is used. "
866
- "Use new data type name <%s> instead.",
867
- name, new_type_name);
868
- }
864
+ if (object) {
865
+ rb_warn("deprecated old data type name <%s> is used. "
866
+ "Use new data type name <%s> instead.",
867
+ name, new_type_name);
868
+ }
869
869
  #endif
870
- }
870
+ }
871
871
  }
872
872
 
873
873
  return object;
@@ -900,26 +900,26 @@ rb_grn_context_array_reference (VALUE self, VALUE name_or_id)
900
900
  context = SELF(self);
901
901
  switch (TYPE(name_or_id)) {
902
902
  case T_SYMBOL:
903
- name = rb_id2name(SYM2ID(name_or_id));
904
- name_size = strlen(name);
905
- object = rb_grn_context_get_backward_compatibility(context,
906
- name, name_size);
907
- break;
903
+ name = rb_id2name(SYM2ID(name_or_id));
904
+ name_size = strlen(name);
905
+ object = rb_grn_context_get_backward_compatibility(context,
906
+ name, name_size);
907
+ break;
908
908
  case T_STRING:
909
- name = StringValuePtr(name_or_id);
910
- name_size = RSTRING_LEN(name_or_id);
911
- object = rb_grn_context_get_backward_compatibility(context,
912
- name, name_size);
913
- break;
909
+ name = StringValuePtr(name_or_id);
910
+ name_size = RSTRING_LEN(name_or_id);
911
+ object = rb_grn_context_get_backward_compatibility(context,
912
+ name, name_size);
913
+ break;
914
914
  case T_FIXNUM:
915
- id = NUM2UINT(name_or_id);
916
- object = grn_ctx_at(context, id);
917
- break;
915
+ id = NUM2UINT(name_or_id);
916
+ object = grn_ctx_at(context, id);
917
+ break;
918
918
  default:
919
- rb_raise(rb_eArgError,
920
- "should be String, Symbol or unsigned integer: %s",
921
- rb_grn_inspect(name_or_id));
922
- break;
919
+ rb_raise(rb_eArgError,
920
+ "should be String, Symbol or unsigned integer: %s",
921
+ rb_grn_inspect(name_or_id));
922
+ break;
923
923
  }
924
924
  rb_grn_context_check(context, name_or_id);
925
925
 
@@ -944,13 +944,13 @@ rb_grn_init_context (VALUE mGrn)
944
944
  rb_cv_set(cGrnContext, "@@default_options", Qnil);
945
945
 
946
946
  rb_define_singleton_method(cGrnContext, "default",
947
- rb_grn_context_s_get_default, 0);
947
+ rb_grn_context_s_get_default, 0);
948
948
  rb_define_singleton_method(cGrnContext, "default=",
949
- rb_grn_context_s_set_default, 1);
949
+ rb_grn_context_s_set_default, 1);
950
950
  rb_define_singleton_method(cGrnContext, "default_options",
951
- rb_grn_context_s_get_default_options, 0);
951
+ rb_grn_context_s_get_default_options, 0);
952
952
  rb_define_singleton_method(cGrnContext, "default_options=",
953
- rb_grn_context_s_set_default_options, 1);
953
+ rb_grn_context_s_set_default_options, 1);
954
954
 
955
955
  rb_define_method(cGrnContext, "initialize", rb_grn_context_initialize, -1);
956
956
 
@@ -962,16 +962,16 @@ rb_grn_init_context (VALUE mGrn)
962
962
  rb_define_method(cGrnContext, "encoding", rb_grn_context_get_encoding, 0);
963
963
  rb_define_method(cGrnContext, "encoding=", rb_grn_context_set_encoding, 1);
964
964
  rb_define_method(cGrnContext, "ruby_encoding",
965
- rb_grn_context_get_ruby_encoding, 0);
965
+ rb_grn_context_get_ruby_encoding, 0);
966
966
  rb_define_method(cGrnContext, "match_escalation_threshold",
967
- rb_grn_context_get_match_escalation_threshold, 0);
967
+ rb_grn_context_get_match_escalation_threshold, 0);
968
968
  rb_define_method(cGrnContext, "match_escalation_threshold=",
969
- rb_grn_context_set_match_escalation_threshold, 1);
969
+ rb_grn_context_set_match_escalation_threshold, 1);
970
970
 
971
971
  rb_define_method(cGrnContext, "support_zlib?",
972
- rb_grn_context_support_zlib_p, 0);
972
+ rb_grn_context_support_zlib_p, 0);
973
973
  rb_define_method(cGrnContext, "support_lzo?",
974
- rb_grn_context_support_lzo_p, 0);
974
+ rb_grn_context_support_lzo_p, 0);
975
975
 
976
976
  rb_define_method(cGrnContext, "database", rb_grn_context_get_database, 0);
977
977