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.
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
@@ -44,8 +44,8 @@ rb_grn_fix_size_column_array_reference (VALUE self, VALUE rb_id)
44
44
  grn_obj *value;
45
45
 
46
46
  rb_grn_column_deconstruct(SELF(self), &fix_size_column, &context,
47
- NULL, NULL,
48
- &value, NULL, &range);
47
+ NULL, NULL,
48
+ &value, NULL, &range);
49
49
 
50
50
  id = NUM2UINT(rb_id);
51
51
  GRN_BULK_REWIND(value);
@@ -74,8 +74,8 @@ rb_grn_fix_size_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
74
74
  grn_id id;
75
75
 
76
76
  rb_grn_column_deconstruct(SELF(self), &column, &context,
77
- &domain_id, &domain,
78
- &value, &range_id, &range);
77
+ &domain_id, &domain,
78
+ &value, &range_id, &range);
79
79
 
80
80
  id = NUM2UINT(rb_id);
81
81
  RVAL2GRNVALUE(rb_value, context, value, range_id, range);
@@ -100,12 +100,12 @@ rb_grn_fix_size_column_integer_set (int argc, VALUE *argv, VALUE self, int flags
100
100
  rb_scan_args(argc, argv, "11", &rb_id, &rb_delta);
101
101
 
102
102
  rb_grn_column_deconstruct(SELF(self), &column, &context,
103
- NULL, NULL,
104
- &value, NULL, NULL);
103
+ NULL, NULL,
104
+ &value, NULL, NULL);
105
105
 
106
106
  id = NUM2UINT(rb_id);
107
107
  if (NIL_P(rb_delta))
108
- rb_delta = INT2NUM(1);
108
+ rb_delta = INT2NUM(1);
109
109
 
110
110
  GRN_BULK_REWIND(value);
111
111
  RVAL2GRNBULK(rb_delta, context, value);
@@ -145,15 +145,15 @@ void
145
145
  rb_grn_init_fix_size_column (VALUE mGrn)
146
146
  {
147
147
  rb_cGrnFixSizeColumn =
148
- rb_define_class_under(mGrn, "FixSizeColumn", rb_cGrnColumn);
148
+ rb_define_class_under(mGrn, "FixSizeColumn", rb_cGrnColumn);
149
149
 
150
150
  rb_define_method(rb_cGrnFixSizeColumn, "[]",
151
- rb_grn_fix_size_column_array_reference, 1);
151
+ rb_grn_fix_size_column_array_reference, 1);
152
152
  rb_define_method(rb_cGrnFixSizeColumn, "[]=",
153
- rb_grn_fix_size_column_array_set, 2);
153
+ rb_grn_fix_size_column_array_set, 2);
154
154
 
155
155
  rb_define_method(rb_cGrnFixSizeColumn, "increment!",
156
- rb_grn_fix_size_column_increment, -1);
156
+ rb_grn_fix_size_column_increment, -1);
157
157
  rb_define_method(rb_cGrnFixSizeColumn, "decrement!",
158
- rb_grn_fix_size_column_decrement, -1);
158
+ rb_grn_fix_size_column_decrement, -1);
159
159
  }
@@ -37,14 +37,14 @@ VALUE
37
37
  rb_grn_tokyo_geo_point_new_raw (VALUE latitude, VALUE longitude)
38
38
  {
39
39
  return rb_funcall(rb_cGrnTokyoGeoPoint, rb_intern("new"), 2,
40
- latitude, longitude);
40
+ latitude, longitude);
41
41
  }
42
42
 
43
43
  VALUE
44
44
  rb_grn_wgs84_geo_point_new_raw (VALUE latitude, VALUE longitude)
45
45
  {
46
46
  return rb_funcall(rb_cGrnWGS84GeoPoint, rb_intern("new"), 2,
47
- latitude, longitude);
47
+ latitude, longitude);
48
48
  }
49
49
 
50
50
  void
@@ -163,61 +163,61 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
163
163
  rb_scan_args(argc, argv, "01", &options);
164
164
 
165
165
  rb_grn_scan_options(options,
166
- "context", &rb_context,
167
- "name", &rb_name,
166
+ "context", &rb_context,
167
+ "name", &rb_name,
168
168
  "path", &rb_path,
169
- "persistent", &rb_persistent,
170
- "key_normalize", &rb_key_normalize,
171
- "key_type", &rb_key_type,
172
- "value_type", &rb_value_type,
173
- "default_tokenizer", &rb_default_tokenizer,
174
- "sub_records", &rb_sub_records,
175
- "normalizer", &rb_normalizer,
176
- NULL);
169
+ "persistent", &rb_persistent,
170
+ "key_normalize", &rb_key_normalize,
171
+ "key_type", &rb_key_type,
172
+ "value_type", &rb_value_type,
173
+ "default_tokenizer", &rb_default_tokenizer,
174
+ "sub_records", &rb_sub_records,
175
+ "normalizer", &rb_normalizer,
176
+ NULL);
177
177
 
178
178
  context = rb_grn_context_ensure(&rb_context);
179
179
 
180
180
  if (!NIL_P(rb_name)) {
181
181
  name = StringValuePtr(rb_name);
182
- name_size = RSTRING_LEN(rb_name);
183
- flags |= GRN_OBJ_PERSISTENT;
182
+ name_size = RSTRING_LEN(rb_name);
183
+ flags |= GRN_OBJ_PERSISTENT;
184
184
  }
185
185
 
186
186
  if (!NIL_P(rb_path)) {
187
187
  path = StringValueCStr(rb_path);
188
- flags |= GRN_OBJ_PERSISTENT;
188
+ flags |= GRN_OBJ_PERSISTENT;
189
189
  }
190
190
 
191
191
  if (RVAL2CBOOL(rb_persistent))
192
- flags |= GRN_OBJ_PERSISTENT;
192
+ flags |= GRN_OBJ_PERSISTENT;
193
193
 
194
194
  if (RVAL2CBOOL(rb_key_normalize))
195
- flags |= GRN_OBJ_KEY_NORMALIZE;
195
+ flags |= GRN_OBJ_KEY_NORMALIZE;
196
196
 
197
197
  if (NIL_P(rb_key_type)) {
198
- key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
198
+ key_type = grn_ctx_at(context, GRN_DB_SHORT_TEXT);
199
199
  } else {
200
- key_type = RVAL2GRNOBJECT(rb_key_type, &context);
200
+ key_type = RVAL2GRNOBJECT(rb_key_type, &context);
201
201
  }
202
202
 
203
203
  if (!NIL_P(rb_value_type))
204
- value_type = RVAL2GRNOBJECT(rb_value_type, &context);
204
+ value_type = RVAL2GRNOBJECT(rb_value_type, &context);
205
205
 
206
206
  if (RVAL2CBOOL(rb_sub_records))
207
- flags |= GRN_OBJ_WITH_SUBREC;
207
+ flags |= GRN_OBJ_WITH_SUBREC;
208
208
 
209
209
  table = grn_table_create(context, name, name_size, path,
210
- flags, key_type, value_type);
210
+ flags, key_type, value_type);
211
211
  if (!table)
212
- rb_grn_context_check(context, rb_ary_new4(argc, argv));
212
+ rb_grn_context_check(context, rb_ary_new4(argc, argv));
213
213
  rb_table = GRNOBJECT2RVAL(klass, context, table, GRN_TRUE);
214
214
 
215
215
  if (!NIL_P(rb_default_tokenizer))
216
- rb_funcall(rb_table, rb_intern("default_tokenizer="), 1,
217
- rb_default_tokenizer);
216
+ rb_funcall(rb_table, rb_intern("default_tokenizer="), 1,
217
+ rb_default_tokenizer);
218
218
  if (!NIL_P(rb_normalizer))
219
- rb_funcall(rb_table, rb_intern("normalizer="), 1,
220
- rb_normalizer);
219
+ rb_funcall(rb_table, rb_intern("normalizer="), 1,
220
+ rb_normalizer);
221
221
 
222
222
  if (rb_block_given_p())
223
223
  return rb_ensure(rb_yield, rb_table, rb_grn_object_close, rb_table);
@@ -263,30 +263,30 @@ rb_grn_hash_search (int argc, VALUE *argv, VALUE self)
263
263
  VALUE rb_key, options, rb_result;
264
264
 
265
265
  rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
266
- &key, &domain_id, &domain,
267
- NULL, NULL, NULL,
268
- NULL);
266
+ &key, &domain_id, &domain,
267
+ NULL, NULL, NULL,
268
+ NULL);
269
269
 
270
270
  rb_scan_args(argc, argv, "11", &rb_key, &options);
271
271
 
272
272
  RVAL2GRNKEY(rb_key, context, key, domain_id, domain, self);
273
273
 
274
274
  rb_grn_scan_options(options,
275
- "result", &rb_result,
276
- NULL);
275
+ "result", &rb_result,
276
+ NULL);
277
277
 
278
278
  if (NIL_P(rb_result)) {
279
- result = grn_table_create(context, NULL, 0, NULL,
280
- GRN_OBJ_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
281
- table, 0);
282
- rb_grn_context_check(context, self);
283
- rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
279
+ result = grn_table_create(context, NULL, 0, NULL,
280
+ GRN_OBJ_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
281
+ table, 0);
282
+ rb_grn_context_check(context, self);
283
+ rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
284
284
  } else {
285
- result = RVAL2GRNOBJECT(rb_result, &context);
285
+ result = RVAL2GRNOBJECT(rb_result, &context);
286
286
  }
287
287
 
288
288
  rc = grn_obj_search(context, table, key,
289
- result, GRN_OP_OR, NULL);
289
+ result, GRN_OP_OR, NULL);
290
290
  rb_grn_rc_check(rc, self);
291
291
 
292
292
  return rb_result;
@@ -300,7 +300,7 @@ rb_grn_init_hash (VALUE mGrn)
300
300
  rb_include_module(rb_cGrnHash, rb_mGrnTableKeySupport);
301
301
 
302
302
  rb_define_singleton_method(rb_cGrnHash, "create",
303
- rb_grn_hash_s_create, -1);
303
+ rb_grn_hash_s_create, -1);
304
304
 
305
305
  rb_define_method(rb_cGrnHash, "search", rb_grn_hash_search, -1);
306
306
  }
@@ -36,10 +36,10 @@ VALUE rb_cGrnIndexColumn;
36
36
 
37
37
  void
38
38
  rb_grn_index_column_finalizer (grn_ctx *context, grn_obj *object,
39
- RbGrnIndexColumn *rb_grn_index_column)
39
+ RbGrnIndexColumn *rb_grn_index_column)
40
40
  {
41
41
  if (!context)
42
- return;
42
+ return;
43
43
 
44
44
  grn_obj_unlink(context, rb_grn_index_column->id_query);
45
45
  grn_obj_unlink(context, rb_grn_index_column->string_query);
@@ -50,7 +50,7 @@ rb_grn_index_column_finalizer (grn_ctx *context, grn_obj *object,
50
50
 
51
51
  void
52
52
  rb_grn_index_column_bind (RbGrnIndexColumn *rb_grn_index_column,
53
- grn_ctx *context, grn_obj *column)
53
+ grn_ctx *context, grn_obj *column)
54
54
  {
55
55
  RbGrnObject *rb_grn_object;
56
56
 
@@ -58,41 +58,41 @@ rb_grn_index_column_bind (RbGrnIndexColumn *rb_grn_index_column,
58
58
  rb_grn_object = RB_GRN_OBJECT(rb_grn_index_column);
59
59
 
60
60
  rb_grn_index_column->old_value = grn_obj_open(context, GRN_BULK, 0,
61
- rb_grn_object->range_id);
61
+ rb_grn_object->range_id);
62
62
 
63
63
  rb_grn_index_column->id_query = grn_obj_open(context, GRN_BULK, 0,
64
- rb_grn_object->domain_id);
64
+ rb_grn_object->domain_id);
65
65
  rb_grn_index_column->string_query = grn_obj_open(context, GRN_BULK,
66
- GRN_OBJ_DO_SHALLOW_COPY,
67
- GRN_DB_SHORT_TEXT);
66
+ GRN_OBJ_DO_SHALLOW_COPY,
67
+ GRN_DB_SHORT_TEXT);
68
68
  }
69
69
 
70
70
  void
71
71
  rb_grn_index_column_deconstruct (RbGrnIndexColumn *rb_grn_index_column,
72
- grn_obj **column,
73
- grn_ctx **context,
74
- grn_id *domain_id,
75
- grn_obj **domain,
76
- grn_obj **value,
77
- grn_obj **old_value,
78
- grn_id *range_id,
79
- grn_obj **range,
80
- grn_obj **id_query,
81
- grn_obj **string_query)
72
+ grn_obj **column,
73
+ grn_ctx **context,
74
+ grn_id *domain_id,
75
+ grn_obj **domain,
76
+ grn_obj **value,
77
+ grn_obj **old_value,
78
+ grn_id *range_id,
79
+ grn_obj **range,
80
+ grn_obj **id_query,
81
+ grn_obj **string_query)
82
82
  {
83
83
  RbGrnObject *rb_grn_object;
84
84
 
85
85
  rb_grn_object = RB_GRN_OBJECT(rb_grn_index_column);
86
86
  rb_grn_column_deconstruct(RB_GRN_COLUMN(rb_grn_object), column, context,
87
- domain_id, domain, value,
88
- range_id, range);
87
+ domain_id, domain, value,
88
+ range_id, range);
89
89
 
90
90
  if (old_value)
91
- *old_value = rb_grn_index_column->old_value;
91
+ *old_value = rb_grn_index_column->old_value;
92
92
  if (id_query)
93
- *id_query = rb_grn_index_column->id_query;
93
+ *id_query = rb_grn_index_column->id_query;
94
94
  if (string_query)
95
- *string_query = rb_grn_index_column->string_query;
95
+ *string_query = rb_grn_index_column->string_query;
96
96
  }
97
97
 
98
98
  /*
@@ -174,47 +174,47 @@ rb_grn_index_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
174
174
  original_rb_value = rb_value;
175
175
 
176
176
  rb_grn_index_column_deconstruct(SELF(self), &column, &context,
177
- NULL, NULL,
178
- &new_value, &old_value,
179
- NULL, &range,
180
- NULL, NULL);
177
+ NULL, NULL,
178
+ &new_value, &old_value,
179
+ NULL, &range,
180
+ NULL, NULL);
181
181
 
182
182
  id = RVAL2GRNID(rb_id, context, range, self);
183
183
 
184
184
  if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_value, rb_cHash))) {
185
- VALUE hash_value;
186
- hash_value = rb_hash_new();
187
- rb_hash_aset(hash_value, RB_GRN_INTERN("value"), rb_value);
188
- rb_value = hash_value;
185
+ VALUE hash_value;
186
+ hash_value = rb_hash_new();
187
+ rb_hash_aset(hash_value, RB_GRN_INTERN("value"), rb_value);
188
+ rb_value = hash_value;
189
189
  }
190
190
 
191
191
  rb_grn_scan_options(rb_value,
192
- "section", &rb_section,
193
- "old_value", &rb_old_value,
194
- "value", &rb_new_value,
195
- NULL);
192
+ "section", &rb_section,
193
+ "old_value", &rb_old_value,
194
+ "value", &rb_new_value,
195
+ NULL);
196
196
 
197
197
  if (NIL_P(rb_section))
198
- section = 1;
198
+ section = 1;
199
199
  else
200
- section = NUM2UINT(rb_section);
200
+ section = NUM2UINT(rb_section);
201
201
 
202
202
  if (NIL_P(rb_old_value)) {
203
- old_value = NULL;
203
+ old_value = NULL;
204
204
  } else {
205
- GRN_BULK_REWIND(old_value);
206
- RVAL2GRNBULK(rb_old_value, context, old_value);
205
+ GRN_BULK_REWIND(old_value);
206
+ RVAL2GRNBULK(rb_old_value, context, old_value);
207
207
  }
208
208
 
209
209
  if (NIL_P(rb_new_value)) {
210
- new_value = NULL;
210
+ new_value = NULL;
211
211
  } else {
212
- GRN_BULK_REWIND(new_value);
213
- RVAL2GRNBULK(rb_new_value, context, new_value);
212
+ GRN_BULK_REWIND(new_value);
213
+ RVAL2GRNBULK(rb_new_value, context, new_value);
214
214
  }
215
215
 
216
216
  rc = grn_column_index_update(context, column,
217
- id, section, old_value, new_value);
217
+ id, section, old_value, new_value);
218
218
  rb_grn_context_check(context, self);
219
219
  rb_grn_rc_check(rc, self);
220
220
 
@@ -318,9 +318,9 @@ rb_grn_index_column_add (int argc, VALUE *argv, VALUE self)
318
318
  NULL);
319
319
 
320
320
  if (NIL_P(rb_section)) {
321
- section = 1;
321
+ section = 1;
322
322
  } else {
323
- section = NUM2UINT(rb_section);
323
+ section = NUM2UINT(rb_section);
324
324
  }
325
325
 
326
326
  rc = grn_column_index_update(context, column, id, section, NULL, new_value);
@@ -432,9 +432,9 @@ rb_grn_index_column_delete (int argc, VALUE *argv, VALUE self)
432
432
  NULL);
433
433
 
434
434
  if (NIL_P(rb_section)) {
435
- section = 1;
435
+ section = 1;
436
436
  } else {
437
- section = NUM2UINT(rb_section);
437
+ section = NUM2UINT(rb_section);
438
438
  }
439
439
 
440
440
  rc = grn_column_index_update(context, column, id, section, old_value, NULL);
@@ -551,9 +551,9 @@ rb_grn_index_column_update (int argc, VALUE *argv, VALUE self)
551
551
  NULL);
552
552
 
553
553
  if (NIL_P(rb_section)) {
554
- section = 1;
554
+ section = 1;
555
555
  } else {
556
- section = NUM2UINT(rb_section);
556
+ section = NUM2UINT(rb_section);
557
557
  }
558
558
 
559
559
  rc = grn_column_index_update(context, column, id, section,
@@ -582,9 +582,9 @@ rb_grn_index_column_get_sources (VALUE self)
582
582
  VALUE exception;
583
583
 
584
584
  rb_grn_index_column_deconstruct(SELF(self), &column, &context,
585
- NULL, NULL,
586
- NULL, NULL, NULL, NULL,
587
- NULL, NULL);
585
+ NULL, NULL,
586
+ NULL, NULL, NULL, NULL,
587
+ NULL, NULL);
588
588
 
589
589
  GRN_OBJ_INIT(&sources, GRN_BULK, 0, GRN_ID_NIL);
590
590
  grn_obj_get_info(context, column, GRN_INFO_SOURCE, &sources);
@@ -594,19 +594,19 @@ rb_grn_index_column_get_sources (VALUE self)
594
594
  source_ids = (grn_id *)GRN_BULK_HEAD(&sources);
595
595
  rb_sources = rb_ary_new2(n);
596
596
  for (i = 0; i < n; i++) {
597
- grn_obj *source;
598
- VALUE rb_source;
599
-
600
- source = grn_ctx_at(context, *source_ids);
601
- exception = rb_grn_context_to_exception(context, self);
602
- if (!NIL_P(exception)) {
603
- grn_obj_unlink(context, &sources);
604
- rb_exc_raise(exception);
605
- }
606
-
607
- rb_source = GRNOBJECT2RVAL(Qnil, context, source, GRN_FALSE);
608
- rb_ary_push(rb_sources, rb_source);
609
- source_ids++;
597
+ grn_obj *source;
598
+ VALUE rb_source;
599
+
600
+ source = grn_ctx_at(context, *source_ids);
601
+ exception = rb_grn_context_to_exception(context, self);
602
+ if (!NIL_P(exception)) {
603
+ grn_obj_unlink(context, &sources);
604
+ rb_exc_raise(exception);
605
+ }
606
+
607
+ rb_source = GRNOBJECT2RVAL(Qnil, context, source, GRN_FALSE);
608
+ rb_ary_push(rb_sources, rb_source);
609
+ source_ids++;
610
610
  }
611
611
  grn_obj_unlink(context, &sources);
612
612
 
@@ -615,64 +615,64 @@ rb_grn_index_column_get_sources (VALUE self)
615
615
 
616
616
  static grn_id
617
617
  resolve_source_id (grn_ctx *context, grn_obj *column, grn_id range_id,
618
- VALUE rb_source)
618
+ VALUE rb_source)
619
619
  {
620
620
  grn_id source_id;
621
621
 
622
622
  if (CBOOL2RVAL(rb_obj_is_kind_of(rb_source, rb_cInteger))) {
623
- source_id = NUM2UINT(rb_source);
623
+ source_id = NUM2UINT(rb_source);
624
624
  } else {
625
- grn_obj *source;
626
- grn_bool need_source_unlink = GRN_FALSE;
627
-
628
- if (TYPE(rb_source) == T_STRING) {
629
- grn_obj *table;
630
- const char *name;
631
- const char *dot_point;
632
- int length;
633
-
634
- table = grn_ctx_at(context, grn_obj_get_range(context, column));
635
- name = StringValueCStr(rb_source);
636
- length = RSTRING_LEN(rb_source);
637
- dot_point = strstr(name, ".");
638
- if (dot_point) {
639
- char table_name[4096];
640
- int table_name_length;
641
-
642
- table_name_length = grn_obj_name(context, table,
643
- table_name, sizeof(table_name));
644
- table_name[table_name_length] = '\0';
645
- if (strncmp(table_name, name, dot_point - name) != 0) {
646
- rb_raise(rb_eArgError,
647
- "wrong table's column: <%s>: "
648
- "expected table: <%s>",
649
- name, table_name);
650
- }
651
- length -= (dot_point - name) + 1;
652
- name = dot_point + 1;
653
- }
654
- source = grn_obj_column(context, table, name, length);
655
- need_source_unlink = GRN_TRUE;
656
- } else {
657
- source = RVAL2GRNOBJECT(rb_source, &context);
658
- }
659
- rb_grn_context_check(context, rb_source);
660
- if (source->header.type == GRN_ACCESSOR) {
661
- char name[256];
662
- int length;
663
- length = grn_column_name(context, source, name, sizeof(name));
664
- name[length] = '\0';
665
- if (strcmp(name, "_key") != 0) {
666
- rb_raise(rb_eArgError,
667
- "source accessor must be '_key': <%s>", name);
668
- }
669
- source_id = range_id;
670
- } else {
671
- source_id = grn_obj_id(context, source);
672
- }
673
- if (need_source_unlink) {
674
- grn_obj_unlink(context, source);
675
- }
625
+ grn_obj *source;
626
+ grn_bool need_source_unlink = GRN_FALSE;
627
+
628
+ if (TYPE(rb_source) == T_STRING) {
629
+ grn_obj *table;
630
+ const char *name;
631
+ const char *dot_point;
632
+ int length;
633
+
634
+ table = grn_ctx_at(context, grn_obj_get_range(context, column));
635
+ name = StringValueCStr(rb_source);
636
+ length = RSTRING_LEN(rb_source);
637
+ dot_point = strstr(name, ".");
638
+ if (dot_point) {
639
+ char table_name[4096];
640
+ int table_name_length;
641
+
642
+ table_name_length = grn_obj_name(context, table,
643
+ table_name, sizeof(table_name));
644
+ table_name[table_name_length] = '\0';
645
+ if (strncmp(table_name, name, dot_point - name) != 0) {
646
+ rb_raise(rb_eArgError,
647
+ "wrong table's column: <%s>: "
648
+ "expected table: <%s>",
649
+ name, table_name);
650
+ }
651
+ length -= (dot_point - name) + 1;
652
+ name = dot_point + 1;
653
+ }
654
+ source = grn_obj_column(context, table, name, length);
655
+ need_source_unlink = GRN_TRUE;
656
+ } else {
657
+ source = RVAL2GRNOBJECT(rb_source, &context);
658
+ }
659
+ rb_grn_context_check(context, rb_source);
660
+ if (source->header.type == GRN_ACCESSOR) {
661
+ char name[256];
662
+ int length;
663
+ length = grn_column_name(context, source, name, sizeof(name));
664
+ name[length] = '\0';
665
+ if (strcmp(name, "_key") != 0) {
666
+ rb_raise(rb_eArgError,
667
+ "source accessor must be '_key': <%s>", name);
668
+ }
669
+ source_id = range_id;
670
+ } else {
671
+ source_id = grn_obj_id(context, source);
672
+ }
673
+ if (need_source_unlink) {
674
+ grn_obj_unlink(context, source);
675
+ }
676
676
  }
677
677
 
678
678
  return source_id;
@@ -697,30 +697,30 @@ rb_grn_index_column_set_sources (VALUE self, VALUE rb_sources)
697
697
  grn_rc rc;
698
698
 
699
699
  rb_grn_index_column_deconstruct(SELF(self), &column, &context,
700
- NULL, NULL,
701
- NULL, NULL,
702
- &range_id, NULL,
703
- NULL, NULL);
700
+ NULL, NULL,
701
+ NULL, NULL,
702
+ &range_id, NULL,
703
+ NULL, NULL);
704
704
 
705
705
  n = RARRAY_LEN(rb_sources);
706
706
  rb_source_values = RARRAY_PTR(rb_sources);
707
707
  sources = ALLOCA_N(grn_id, n);
708
708
  for (i = 0; i < n; i++) {
709
- sources[i] = resolve_source_id(context, column, range_id,
710
- rb_source_values[i]);
709
+ sources[i] = resolve_source_id(context, column, range_id,
710
+ rb_source_values[i]);
711
711
  }
712
712
 
713
713
  {
714
- grn_obj bulk_sources;
715
- GRN_OBJ_INIT(&bulk_sources, GRN_BULK, 0, GRN_ID_NIL);
716
- GRN_TEXT_SET(context, &bulk_sources, sources, n * sizeof(grn_id));
717
- rc = grn_obj_set_info(context, column, GRN_INFO_SOURCE, &bulk_sources);
718
- exception = rb_grn_context_to_exception(context, self);
719
- grn_obj_unlink(context, &bulk_sources);
714
+ grn_obj bulk_sources;
715
+ GRN_OBJ_INIT(&bulk_sources, GRN_BULK, 0, GRN_ID_NIL);
716
+ GRN_TEXT_SET(context, &bulk_sources, sources, n * sizeof(grn_id));
717
+ rc = grn_obj_set_info(context, column, GRN_INFO_SOURCE, &bulk_sources);
718
+ exception = rb_grn_context_to_exception(context, self);
719
+ grn_obj_unlink(context, &bulk_sources);
720
720
  }
721
721
 
722
722
  if (!NIL_P(exception))
723
- rb_exc_raise(exception);
723
+ rb_exc_raise(exception);
724
724
  rb_grn_rc_check(rc, self);
725
725
 
726
726
  return Qnil;
@@ -736,7 +736,7 @@ static VALUE
736
736
  rb_grn_index_column_set_source (VALUE self, VALUE rb_source)
737
737
  {
738
738
  if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_source, rb_cArray)))
739
- rb_source = rb_ary_new3(1, rb_source);
739
+ rb_source = rb_ary_new3(1, rb_source);
740
740
 
741
741
  return rb_grn_index_column_set_sources(self, rb_source);
742
742
  }
@@ -785,37 +785,37 @@ rb_grn_index_column_search (int argc, VALUE *argv, VALUE self)
785
785
  VALUE rb_query, options, rb_result, rb_operator;
786
786
 
787
787
  rb_grn_index_column_deconstruct(SELF(self), &column, &context,
788
- NULL, NULL,
789
- NULL, NULL, NULL, &range,
790
- &id_query, &string_query);
788
+ NULL, NULL,
789
+ NULL, NULL, NULL, &range,
790
+ &id_query, &string_query);
791
791
 
792
792
  rb_scan_args(argc, argv, "11", &rb_query, &options);
793
793
 
794
794
  if (CBOOL2RVAL(rb_obj_is_kind_of(rb_query, rb_cInteger))) {
795
- grn_id id;
796
- id = NUM2UINT(rb_query);
797
- GRN_TEXT_SET(context, id_query, &id, sizeof(grn_id));
798
- query = id_query;
795
+ grn_id id;
796
+ id = NUM2UINT(rb_query);
797
+ GRN_TEXT_SET(context, id_query, &id, sizeof(grn_id));
798
+ query = id_query;
799
799
  } else {
800
- const char *_query;
801
- _query = StringValuePtr(rb_query);
802
- GRN_TEXT_SET(context, string_query, _query, RSTRING_LEN(rb_query));
803
- query = string_query;
800
+ const char *_query;
801
+ _query = StringValuePtr(rb_query);
802
+ GRN_TEXT_SET(context, string_query, _query, RSTRING_LEN(rb_query));
803
+ query = string_query;
804
804
  }
805
805
 
806
806
  rb_grn_scan_options(options,
807
- "result", &rb_result,
808
- "operator", &rb_operator,
809
- NULL);
807
+ "result", &rb_result,
808
+ "operator", &rb_operator,
809
+ NULL);
810
810
 
811
811
  if (NIL_P(rb_result)) {
812
- result = grn_table_create(context, NULL, 0, NULL,
813
- GRN_OBJ_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
814
- range, 0);
815
- rb_grn_context_check(context, self);
816
- rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
812
+ result = grn_table_create(context, NULL, 0, NULL,
813
+ GRN_OBJ_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
814
+ range, 0);
815
+ rb_grn_context_check(context, self);
816
+ rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);
817
817
  } else {
818
- result = RVAL2GRNOBJECT(rb_result, &context);
818
+ result = RVAL2GRNOBJECT(rb_result, &context);
819
819
  }
820
820
 
821
821
  operator = RVAL2GRNOPERATOR(rb_operator);
@@ -837,9 +837,9 @@ rb_grn_index_column_with_section_p (VALUE self)
837
837
  grn_obj *column;
838
838
 
839
839
  rb_grn_index_column_deconstruct(SELF(self), &column, NULL,
840
- NULL, NULL,
841
- NULL, NULL, NULL, NULL,
842
- NULL, NULL);
840
+ NULL, NULL,
841
+ NULL, NULL, NULL, NULL,
842
+ NULL, NULL);
843
843
 
844
844
  return CBOOL2RVAL(column->header.flags & GRN_OBJ_WITH_SECTION);
845
845
  }
@@ -855,9 +855,9 @@ rb_grn_index_column_with_weight_p (VALUE self)
855
855
  grn_obj *column;
856
856
 
857
857
  rb_grn_index_column_deconstruct(SELF(self), &column, NULL,
858
- NULL, NULL,
859
- NULL, NULL, NULL, NULL,
860
- NULL, NULL);
858
+ NULL, NULL,
859
+ NULL, NULL, NULL, NULL,
860
+ NULL, NULL);
861
861
 
862
862
  return CBOOL2RVAL(column->header.flags & GRN_OBJ_WITH_WEIGHT);
863
863
  }
@@ -873,9 +873,9 @@ rb_grn_index_column_with_position_p (VALUE self)
873
873
  grn_obj *column;
874
874
 
875
875
  rb_grn_index_column_deconstruct(SELF(self), &column, NULL,
876
- NULL, NULL,
877
- NULL, NULL, NULL, NULL,
878
- NULL, NULL);
876
+ NULL, NULL,
877
+ NULL, NULL, NULL, NULL,
878
+ NULL, NULL);
879
879
 
880
880
  return CBOOL2RVAL(column->header.flags & GRN_OBJ_WITH_POSITION);
881
881
  }
@@ -918,83 +918,83 @@ rb_grn_index_column_open_cursor (int argc, VALUE *argv, VALUE self)
918
918
  VALUE rb_cursor;
919
919
 
920
920
  rb_grn_index_column_deconstruct(SELF(self), &column, &context,
921
- NULL, NULL,
922
- NULL, NULL,
923
- NULL, &range_object,
924
- NULL, NULL);
921
+ NULL, NULL,
922
+ NULL, NULL,
923
+ NULL, &range_object,
924
+ NULL, NULL);
925
925
 
926
926
  rb_scan_args(argc, argv, "11", &rb_table_cursor, &options);
927
927
  rb_grn_scan_options(options,
928
- "with_section", &rb_with_section,
929
- "with_weight", &rb_with_weight,
930
- "with_position", &rb_with_position,
931
- NULL);
928
+ "with_section", &rb_with_section,
929
+ "with_weight", &rb_with_weight,
930
+ "with_position", &rb_with_position,
931
+ NULL);
932
932
 
933
933
  table_cursor = RVAL2GRNTABLECURSOR(rb_table_cursor, NULL);
934
934
  rb_table = GRNOBJECT2RVAL(Qnil, context, range_object, GRN_FALSE);
935
935
  rb_lexicon = rb_iv_get(rb_table_cursor, "@table");
936
936
 
937
937
  if (NIL_P(rb_with_section)) {
938
- flags |= column->header.flags & GRN_OBJ_WITH_SECTION;
938
+ flags |= column->header.flags & GRN_OBJ_WITH_SECTION;
939
939
  } else if (RVAL2CBOOL(rb_with_section)) {
940
- flags |= GRN_OBJ_WITH_SECTION;
940
+ flags |= GRN_OBJ_WITH_SECTION;
941
941
  }
942
942
 
943
943
  if (NIL_P(rb_with_weight)) {
944
- flags |= column->header.flags & GRN_OBJ_WITH_WEIGHT;
944
+ flags |= column->header.flags & GRN_OBJ_WITH_WEIGHT;
945
945
  } else if (RVAL2CBOOL(rb_with_weight)) {
946
- flags |= GRN_OBJ_WITH_WEIGHT;
946
+ flags |= GRN_OBJ_WITH_WEIGHT;
947
947
  }
948
948
 
949
949
  if (NIL_P(rb_with_position)) {
950
- flags |= column->header.flags & GRN_OBJ_WITH_POSITION;
950
+ flags |= column->header.flags & GRN_OBJ_WITH_POSITION;
951
951
  } else if (RVAL2CBOOL(rb_with_position)) {
952
- flags |= GRN_OBJ_WITH_POSITION;
952
+ flags |= GRN_OBJ_WITH_POSITION;
953
953
  }
954
954
 
955
955
  index_cursor = grn_index_cursor_open(context, table_cursor,
956
- column, rid_min, rid_max, flags);
956
+ column, rid_min, rid_max, flags);
957
957
 
958
958
  rb_cursor = GRNINDEXCURSOR2RVAL(context, index_cursor, rb_table, rb_lexicon);
959
959
 
960
960
  if (rb_block_given_p())
961
- return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
961
+ return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
962
962
  else
963
- return rb_cursor;
963
+ return rb_cursor;
964
964
  }
965
965
 
966
966
  void
967
967
  rb_grn_init_index_column (VALUE mGrn)
968
968
  {
969
969
  rb_cGrnIndexColumn =
970
- rb_define_class_under(mGrn, "IndexColumn", rb_cGrnColumn);
970
+ rb_define_class_under(mGrn, "IndexColumn", rb_cGrnColumn);
971
971
 
972
972
  rb_define_method(rb_cGrnIndexColumn, "[]=",
973
- rb_grn_index_column_array_set, 2);
973
+ rb_grn_index_column_array_set, 2);
974
974
 
975
975
  rb_define_method(rb_cGrnIndexColumn, "add",
976
- rb_grn_index_column_add, -1);
976
+ rb_grn_index_column_add, -1);
977
977
  rb_define_method(rb_cGrnIndexColumn, "delete",
978
- rb_grn_index_column_delete, -1);
978
+ rb_grn_index_column_delete, -1);
979
979
  rb_define_method(rb_cGrnIndexColumn, "update",
980
- rb_grn_index_column_update, -1);
980
+ rb_grn_index_column_update, -1);
981
981
 
982
982
  rb_define_method(rb_cGrnIndexColumn, "sources",
983
- rb_grn_index_column_get_sources, 0);
983
+ rb_grn_index_column_get_sources, 0);
984
984
  rb_define_method(rb_cGrnIndexColumn, "sources=",
985
- rb_grn_index_column_set_sources, 1);
985
+ rb_grn_index_column_set_sources, 1);
986
986
  rb_define_method(rb_cGrnIndexColumn, "source=",
987
- rb_grn_index_column_set_source, 1);
987
+ rb_grn_index_column_set_source, 1);
988
988
 
989
989
  rb_define_method(rb_cGrnIndexColumn, "search",
990
- rb_grn_index_column_search, -1);
990
+ rb_grn_index_column_search, -1);
991
991
 
992
992
  rb_define_method(rb_cGrnIndexColumn, "with_section?",
993
- rb_grn_index_column_with_section_p, 0);
993
+ rb_grn_index_column_with_section_p, 0);
994
994
  rb_define_method(rb_cGrnIndexColumn, "with_weight?",
995
- rb_grn_index_column_with_weight_p, 0);
995
+ rb_grn_index_column_with_weight_p, 0);
996
996
  rb_define_method(rb_cGrnIndexColumn, "with_position?",
997
- rb_grn_index_column_with_position_p, 0);
997
+ rb_grn_index_column_with_position_p, 0);
998
998
  rb_define_method(rb_cGrnIndexColumn, "open_cursor",
999
- rb_grn_index_column_open_cursor, -1);
999
+ rb_grn_index_column_open_cursor, -1);
1000
1000
  }