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
@@ -35,7 +35,7 @@ grn_obj *
35
35
  rb_grn_type_from_ruby_object (VALUE object)
36
36
  {
37
37
  if (!RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cGrnType))) {
38
- rb_raise(rb_eTypeError, "not a groonga type");
38
+ rb_raise(rb_eTypeError, "not a groonga type");
39
39
  }
40
40
 
41
41
  return RVAL2GRNOBJECT(object, NULL);
@@ -43,7 +43,7 @@ rb_grn_type_from_ruby_object (VALUE object)
43
43
 
44
44
  VALUE
45
45
  rb_grn_type_to_ruby_object (grn_ctx *context, grn_obj *type,
46
- grn_bool owner)
46
+ grn_bool owner)
47
47
  {
48
48
  return GRNOBJECT2RVAL(rb_cGrnType, context, type, owner);
49
49
  }
@@ -82,10 +82,10 @@ rb_grn_type_initialize (int argc, VALUE *argv, VALUE self)
82
82
  rb_scan_args(argc, argv, "11", &rb_name, &options);
83
83
 
84
84
  rb_grn_scan_options(options,
85
- "context", &rb_context,
86
- "type", &rb_type,
87
- "size", &rb_size,
88
- NULL);
85
+ "context", &rb_context,
86
+ "type", &rb_type,
87
+ "size", &rb_size,
88
+ NULL);
89
89
 
90
90
  name = StringValuePtr(rb_name);
91
91
  name_size = RSTRING_LEN(rb_name);
@@ -93,25 +93,25 @@ rb_grn_type_initialize (int argc, VALUE *argv, VALUE self)
93
93
  context = rb_grn_context_ensure(&rb_context);
94
94
 
95
95
  if (NIL_P(rb_type) ||
96
- rb_grn_equal_option(rb_type, "variable")) {
96
+ rb_grn_equal_option(rb_type, "variable")) {
97
97
  flags = GRN_OBJ_KEY_VAR_SIZE;
98
98
  } else if (rb_grn_equal_option(rb_type, "integer") ||
99
99
  rb_grn_equal_option(rb_type, "int")) {
100
- flags = GRN_OBJ_KEY_INT;
100
+ flags = GRN_OBJ_KEY_INT;
101
101
  size = sizeof(int);
102
102
  } else if (rb_grn_equal_option(rb_type, "unsigned_integer") ||
103
- rb_grn_equal_option(rb_type, "uint")) {
104
- flags = GRN_OBJ_KEY_UINT;
103
+ rb_grn_equal_option(rb_type, "uint")) {
104
+ flags = GRN_OBJ_KEY_UINT;
105
105
  size = sizeof(unsigned int);
106
106
  } else if (rb_grn_equal_option(rb_type, "float")) {
107
- flags = GRN_OBJ_KEY_FLOAT;
107
+ flags = GRN_OBJ_KEY_FLOAT;
108
108
  size = sizeof(double);
109
109
  } else {
110
- rb_raise(rb_eArgError,
111
- ":type should be one of "
112
- "[:integer, :int, :unsigned_integer, :uint, "
113
- ":float, :variable]: %s",
114
- rb_grn_inspect(options));
110
+ rb_raise(rb_eArgError,
111
+ ":type should be one of "
112
+ "[:integer, :int, :unsigned_integer, :uint, "
113
+ ":float, :variable]: %s",
114
+ rb_grn_inspect(options));
115
115
  }
116
116
 
117
117
  if (NIL_P(rb_size)) {
@@ -227,10 +227,10 @@ rb_grn_init_type (VALUE mGrn)
227
227
  rb_define_method(rb_cGrnType, "flags", rb_grn_type_flags, 0);
228
228
  rb_define_method(rb_cGrnType, "fixed_size?", rb_grn_type_fixed_size_p, 0);
229
229
  rb_define_method(rb_cGrnType, "variable_size?",
230
- rb_grn_type_variable_size_p, 0);
230
+ rb_grn_type_variable_size_p, 0);
231
231
 
232
232
  rb_define_method(rb_cGrnType, "unsigned_integer?",
233
- rb_grn_type_unsigned_integer_p, 0);
233
+ rb_grn_type_unsigned_integer_p, 0);
234
234
  rb_define_alias(rb_cGrnType, "uint?", "unsigned_integer?");
235
235
 
236
236
  rb_define_method(rb_cGrnType, "integer?", rb_grn_type_integer_p, 0);
@@ -33,62 +33,62 @@ rb_grn_inspect (VALUE object)
33
33
  const char *
34
34
  rb_grn_inspect_type (unsigned char type)
35
35
  {
36
- switch (type) {
37
- case GRN_VOID:
38
- return "void";
39
- case GRN_BULK:
40
- return "bulk";
41
- case GRN_PTR:
42
- return "ptr";
43
- case GRN_UVECTOR:
44
- return "uvector";
45
- case GRN_PVECTOR:
46
- return "pvector";
47
- case GRN_MSG:
48
- return "msg";
49
- case GRN_QUERY:
50
- return "query";
51
- case GRN_ACCESSOR:
52
- return "accessor";
53
- case GRN_SNIP:
54
- return "snip";
55
- case GRN_PATSNIP:
56
- return "patsnip";
57
- case GRN_CURSOR_TABLE_HASH_KEY:
58
- return "cursor-table-hash-key";
59
- case GRN_CURSOR_TABLE_PAT_KEY:
60
- return "cursor-table-pat-key";
61
- case GRN_CURSOR_TABLE_DAT_KEY:
62
- return "cursor-table-dat-key";
63
- case GRN_CURSOR_TABLE_NO_KEY:
64
- return "cursor-table-no-key";
65
- case GRN_CURSOR_COLUMN_INDEX:
66
- return "cursor-column-index";
67
- case GRN_TYPE:
68
- return "type";
69
- case GRN_PROC:
70
- return "proc";
71
- case GRN_EXPR:
72
- return "expr";
73
- case GRN_TABLE_HASH_KEY:
74
- return "table-hash-key";
75
- case GRN_TABLE_PAT_KEY:
76
- return "table-pat-key";
77
- case GRN_TABLE_DAT_KEY:
78
- return "table-dat-key";
79
- case GRN_TABLE_NO_KEY:
80
- return "table-no-key";
81
- case GRN_DB:
82
- return "db";
83
- case GRN_COLUMN_FIX_SIZE:
84
- return "column-fix-size";
85
- case GRN_COLUMN_VAR_SIZE:
86
- return "column-var-size";
87
- case GRN_COLUMN_INDEX:
88
- return "column-index";
89
- default:
90
- return "unknown";
91
- }
36
+ switch (type) {
37
+ case GRN_VOID:
38
+ return "void";
39
+ case GRN_BULK:
40
+ return "bulk";
41
+ case GRN_PTR:
42
+ return "ptr";
43
+ case GRN_UVECTOR:
44
+ return "uvector";
45
+ case GRN_PVECTOR:
46
+ return "pvector";
47
+ case GRN_MSG:
48
+ return "msg";
49
+ case GRN_QUERY:
50
+ return "query";
51
+ case GRN_ACCESSOR:
52
+ return "accessor";
53
+ case GRN_SNIP:
54
+ return "snip";
55
+ case GRN_PATSNIP:
56
+ return "patsnip";
57
+ case GRN_CURSOR_TABLE_HASH_KEY:
58
+ return "cursor-table-hash-key";
59
+ case GRN_CURSOR_TABLE_PAT_KEY:
60
+ return "cursor-table-pat-key";
61
+ case GRN_CURSOR_TABLE_DAT_KEY:
62
+ return "cursor-table-dat-key";
63
+ case GRN_CURSOR_TABLE_NO_KEY:
64
+ return "cursor-table-no-key";
65
+ case GRN_CURSOR_COLUMN_INDEX:
66
+ return "cursor-column-index";
67
+ case GRN_TYPE:
68
+ return "type";
69
+ case GRN_PROC:
70
+ return "proc";
71
+ case GRN_EXPR:
72
+ return "expr";
73
+ case GRN_TABLE_HASH_KEY:
74
+ return "table-hash-key";
75
+ case GRN_TABLE_PAT_KEY:
76
+ return "table-pat-key";
77
+ case GRN_TABLE_DAT_KEY:
78
+ return "table-dat-key";
79
+ case GRN_TABLE_NO_KEY:
80
+ return "table-no-key";
81
+ case GRN_DB:
82
+ return "db";
83
+ case GRN_COLUMN_FIX_SIZE:
84
+ return "column-fix-size";
85
+ case GRN_COLUMN_VAR_SIZE:
86
+ return "column-var-size";
87
+ case GRN_COLUMN_INDEX:
88
+ return "column-index";
89
+ default:
90
+ return "unknown";
91
+ }
92
92
  }
93
93
 
94
94
  void
@@ -199,73 +199,70 @@ rb_grn_bulk_to_ruby_object_by_range_id (grn_ctx *context, grn_obj *bulk,
199
199
  grn_bool success = GRN_TRUE;
200
200
 
201
201
  switch (range_id) {
202
- case GRN_DB_VOID:
202
+ case GRN_DB_VOID:
203
203
  *rb_value = rb_str_new(GRN_TEXT_VALUE(bulk), GRN_TEXT_LEN(bulk));
204
204
  break;
205
- case GRN_DB_BOOL:
205
+ case GRN_DB_BOOL:
206
206
  *rb_value = GRN_BOOL_VALUE(bulk) ? Qtrue : Qfalse;
207
207
  break;
208
- case GRN_DB_INT8:
208
+ case GRN_DB_INT8:
209
209
  *rb_value = INT2NUM(GRN_INT8_VALUE(bulk));
210
210
  break;
211
- case GRN_DB_UINT8:
211
+ case GRN_DB_UINT8:
212
212
  *rb_value = UINT2NUM(GRN_UINT8_VALUE(bulk));
213
213
  break;
214
- case GRN_DB_INT16:
214
+ case GRN_DB_INT16:
215
215
  *rb_value = INT2NUM(GRN_INT16_VALUE(bulk));
216
216
  break;
217
- case GRN_DB_UINT16:
217
+ case GRN_DB_UINT16:
218
218
  *rb_value = UINT2NUM(GRN_UINT16_VALUE(bulk));
219
219
  break;
220
- case GRN_DB_INT32:
220
+ case GRN_DB_INT32:
221
221
  *rb_value = INT2NUM(GRN_INT32_VALUE(bulk));
222
222
  break;
223
- case GRN_DB_UINT32:
223
+ case GRN_DB_UINT32:
224
224
  *rb_value = UINT2NUM(GRN_UINT32_VALUE(bulk));
225
225
  break;
226
- case GRN_DB_INT64:
226
+ case GRN_DB_INT64:
227
227
  *rb_value = LL2NUM(GRN_INT64_VALUE(bulk));
228
228
  break;
229
- case GRN_DB_UINT64:
229
+ case GRN_DB_UINT64:
230
230
  *rb_value = ULL2NUM(GRN_UINT64_VALUE(bulk));
231
231
  break;
232
- case GRN_DB_FLOAT:
232
+ case GRN_DB_FLOAT:
233
233
  *rb_value = rb_float_new(GRN_FLOAT_VALUE(bulk));
234
234
  break;
235
- case GRN_DB_TIME:
236
- {
237
- int64_t time_value, sec, usec;
238
-
239
- time_value = GRN_TIME_VALUE(bulk);
240
- GRN_TIME_UNPACK(time_value, sec, usec);
241
- *rb_value = rb_funcall(rb_cTime, rb_intern("at"), 2,
242
- LL2NUM(sec), LL2NUM(usec));
243
- }
235
+ case GRN_DB_TIME: {
236
+ int64_t time_value, sec, usec;
237
+
238
+ time_value = GRN_TIME_VALUE(bulk);
239
+ GRN_TIME_UNPACK(time_value, sec, usec);
240
+ *rb_value = rb_funcall(rb_cTime, rb_intern("at"), 2,
241
+ LL2NUM(sec), LL2NUM(usec));
244
242
  break;
245
- case GRN_DB_SHORT_TEXT:
246
- case GRN_DB_TEXT:
247
- case GRN_DB_LONG_TEXT:
243
+ }
244
+ case GRN_DB_SHORT_TEXT:
245
+ case GRN_DB_TEXT:
246
+ case GRN_DB_LONG_TEXT:
248
247
  *rb_value = rb_grn_context_rb_string_new(context,
249
248
  GRN_TEXT_VALUE(bulk),
250
249
  GRN_TEXT_LEN(bulk));
251
250
  break;
252
- case GRN_DB_TOKYO_GEO_POINT:
253
- {
254
- int latitude, longitude;
251
+ case GRN_DB_TOKYO_GEO_POINT: {
252
+ int latitude, longitude;
255
253
 
256
- GRN_GEO_POINT_VALUE(bulk, latitude, longitude);
257
- *rb_value = rb_grn_tokyo_geo_point_new(latitude, longitude);
258
- }
254
+ GRN_GEO_POINT_VALUE(bulk, latitude, longitude);
255
+ *rb_value = rb_grn_tokyo_geo_point_new(latitude, longitude);
259
256
  break;
260
- case GRN_DB_WGS84_GEO_POINT:
261
- {
262
- int latitude, longitude;
257
+ }
258
+ case GRN_DB_WGS84_GEO_POINT: {
259
+ int latitude, longitude;
263
260
 
264
- GRN_GEO_POINT_VALUE(bulk, latitude, longitude);
265
- *rb_value = rb_grn_wgs84_geo_point_new(latitude, longitude);
266
- }
261
+ GRN_GEO_POINT_VALUE(bulk, latitude, longitude);
262
+ *rb_value = rb_grn_wgs84_geo_point_new(latitude, longitude);
267
263
  break;
268
- default:
264
+ }
265
+ default:
269
266
  success = GRN_FALSE;
270
267
  break;
271
268
  }
@@ -288,47 +285,46 @@ rb_grn_bulk_to_ruby_object_by_range_type (grn_ctx *context, grn_obj *bulk,
288
285
  return GRN_FALSE;
289
286
 
290
287
  switch (range->header.type) {
291
- case GRN_TABLE_HASH_KEY:
292
- case GRN_TABLE_PAT_KEY:
293
- case GRN_TABLE_DAT_KEY:
294
- case GRN_TABLE_NO_KEY:
295
- {
296
- grn_id id;
297
-
298
- id = *((grn_id *)GRN_BULK_HEAD(bulk));
299
- if (id == GRN_ID_NIL) {
300
- *rb_value = Qnil;
301
- } else {
302
- VALUE rb_range;
288
+ case GRN_TABLE_HASH_KEY:
289
+ case GRN_TABLE_PAT_KEY:
290
+ case GRN_TABLE_DAT_KEY:
291
+ case GRN_TABLE_NO_KEY: {
292
+ grn_id id;
303
293
 
304
- rb_range = GRNOBJECT2RVAL(Qnil, context, range, GRN_FALSE);
305
- *rb_value = rb_grn_record_new(rb_range, id, Qnil);
306
- }
294
+ id = *((grn_id *)GRN_BULK_HEAD(bulk));
295
+ if (id == GRN_ID_NIL) {
296
+ *rb_value = Qnil;
297
+ } else {
298
+ VALUE rb_range;
299
+
300
+ rb_range = GRNOBJECT2RVAL(Qnil, context, range, GRN_FALSE);
301
+ *rb_value = rb_grn_record_new(rb_range, id, Qnil);
307
302
  }
308
303
  break;
309
- case GRN_TYPE:
304
+ }
305
+ case GRN_TYPE:
310
306
  if (range->header.flags & GRN_OBJ_KEY_VAR_SIZE) {
311
307
  *rb_value = rb_grn_context_rb_string_new(context,
312
308
  GRN_BULK_HEAD(bulk),
313
309
  GRN_BULK_VSIZE(bulk));
314
310
  } else {
315
311
  switch (range->header.flags & GRN_OBJ_KEY_MASK) {
316
- case GRN_OBJ_KEY_UINT:
312
+ case GRN_OBJ_KEY_UINT:
317
313
  *rb_value = INT2NUM(GRN_UINT32_VALUE(bulk));
318
314
  break;
319
- case GRN_OBJ_KEY_INT:
315
+ case GRN_OBJ_KEY_INT:
320
316
  *rb_value = INT2NUM(GRN_INT32_VALUE(bulk));
321
317
  break;
322
- case GRN_OBJ_KEY_FLOAT:
318
+ case GRN_OBJ_KEY_FLOAT:
323
319
  *rb_value = rb_float_new(GRN_FLOAT_VALUE(bulk));
324
320
  break;
325
- default:
321
+ default:
326
322
  success = GRN_FALSE;
327
323
  }
328
324
  break;
329
325
  }
330
326
  break;
331
- default:
327
+ default:
332
328
  success = GRN_FALSE;
333
329
  break;
334
330
  }
@@ -375,42 +371,41 @@ rb_grn_bulk_from_ruby_object (VALUE object, grn_ctx *context, grn_obj *bulk)
375
371
  }
376
372
 
377
373
  switch (TYPE(object)) {
378
- case T_NIL:
374
+ case T_NIL:
379
375
  grn_obj_reinit(context, bulk, GRN_DB_VOID, 0);
380
376
  break;
381
- case T_SYMBOL:
377
+ case T_SYMBOL:
382
378
  object = rb_funcall(object, rb_intern("to_s"), 0);
383
- case T_STRING:
379
+ case T_STRING:
384
380
  grn_obj_reinit(context, bulk, GRN_DB_TEXT, 0);
385
381
  rb_grn_context_text_set(context, bulk, object);
386
382
  break;
387
- case T_FIXNUM:
388
- case T_BIGNUM:
389
- {
390
- int64_t int64_value;
391
- int64_value = NUM2LL(object);
392
- if (int64_value <= INT32_MAX) {
393
- grn_obj_reinit(context, bulk, GRN_DB_INT32, 0);
394
- GRN_INT32_SET(context, bulk, int64_value);
395
- } else {
396
- grn_obj_reinit(context, bulk, GRN_DB_INT64, 0);
397
- GRN_INT64_SET(context, bulk, int64_value);
398
- }
383
+ case T_FIXNUM:
384
+ case T_BIGNUM: {
385
+ int64_t int64_value;
386
+ int64_value = NUM2LL(object);
387
+ if (int64_value <= INT32_MAX) {
388
+ grn_obj_reinit(context, bulk, GRN_DB_INT32, 0);
389
+ GRN_INT32_SET(context, bulk, int64_value);
390
+ } else {
391
+ grn_obj_reinit(context, bulk, GRN_DB_INT64, 0);
392
+ GRN_INT64_SET(context, bulk, int64_value);
399
393
  }
400
394
  break;
401
- case T_FLOAT:
395
+ }
396
+ case T_FLOAT:
402
397
  grn_obj_reinit(context, bulk, GRN_DB_FLOAT, 0);
403
398
  GRN_FLOAT_SET(context, bulk, NUM2DBL(object));
404
399
  break;
405
- case T_TRUE:
400
+ case T_TRUE:
406
401
  grn_obj_reinit(context, bulk, GRN_DB_BOOL, 0);
407
402
  GRN_BOOL_SET(context, bulk, GRN_TRUE);
408
403
  break;
409
- case T_FALSE:
404
+ case T_FALSE:
410
405
  grn_obj_reinit(context, bulk, GRN_DB_BOOL, 0);
411
406
  GRN_BOOL_SET(context, bulk, GRN_FALSE);
412
407
  break;
413
- default:
408
+ default:
414
409
  if (RVAL2CBOOL(rb_obj_is_kind_of(object, rb_cTime))) {
415
410
  VALUE sec, usec;
416
411
  int64_t time_value;
@@ -457,14 +452,21 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
457
452
  {
458
453
  const char *string;
459
454
  unsigned int size;
460
- int32_t int32_value;
461
- uint32_t uint32_value;
462
- int64_t int64_value;
463
- uint64_t uint64_value;
464
- int64_t time_value;
465
- double double_value;
466
- grn_geo_point geo_point_value;
467
- grn_id record_id, range;
455
+ union {
456
+ int8_t int8_value;
457
+ uint8_t uint8_value;
458
+ int16_t int16_value;
459
+ uint16_t uint16_value;
460
+ int32_t int32_value;
461
+ uint32_t uint32_value;
462
+ int64_t int64_value;
463
+ uint64_t uint64_value;
464
+ int64_t time_value;
465
+ double double_value;
466
+ grn_geo_point geo_point_value;
467
+ grn_id record_id;
468
+ } value;
469
+ grn_id range;
468
470
  VALUE rb_type_object;
469
471
  grn_obj_flags flags = 0;
470
472
  grn_bool string_p, table_type_p;
@@ -474,75 +476,94 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
474
476
  type->header.type <= GRN_TABLE_NO_KEY);
475
477
 
476
478
  switch (type_id) {
477
- case GRN_DB_INT32:
478
- int32_value = NUM2INT(object);
479
- string = (const char *)&int32_value;
480
- size = sizeof(int32_value);
479
+ case GRN_DB_INT8:
480
+ value.int8_value = NUM2SHORT(object);
481
+ string = (const char *)&(value.int8_value);
482
+ size = sizeof(value.int8_value);
481
483
  break;
482
- case GRN_DB_UINT32:
483
- uint32_value = NUM2UINT(object);
484
- string = (const char *)&uint32_value;
485
- size = sizeof(uint32_value);
484
+ case GRN_DB_UINT8:
485
+ value.uint8_value = NUM2USHORT(object);
486
+ string = (const char *)&(value.uint8_value);
487
+ size = sizeof(value.uint8_value);
486
488
  break;
487
- case GRN_DB_INT64:
488
- int64_value = NUM2LL(object);
489
- string = (const char *)&int64_value;
490
- size = sizeof(int64_value);
489
+ case GRN_DB_INT16:
490
+ value.int16_value = NUM2SHORT(object);
491
+ string = (const char *)&(value.int16_value);
492
+ size = sizeof(value.int16_value);
491
493
  break;
492
- case GRN_DB_UINT64:
493
- uint64_value = NUM2ULL(object);
494
- string = (const char *)&uint64_value;
495
- size = sizeof(uint64_value);
494
+ case GRN_DB_UINT16:
495
+ value.uint16_value = NUM2USHORT(object);
496
+ string = (const char *)&(value.uint16_value);
497
+ size = sizeof(value.uint16_value);
496
498
  break;
497
- case GRN_DB_FLOAT:
498
- double_value = NUM2DBL(object);
499
- string = (const char *)&double_value;
500
- size = sizeof(double_value);
499
+ case GRN_DB_INT32:
500
+ value.int32_value = NUM2INT(object);
501
+ string = (const char *)&(value.int32_value);
502
+ size = sizeof(value.int32_value);
501
503
  break;
502
- case GRN_DB_TIME:
503
- {
504
- VALUE rb_sec, rb_usec;
505
- int64_t sec;
506
- int32_t usec;
507
-
508
- if (string_p) {
509
- ID id_parse;
510
- CONST_ID(id_parse, "parse");
511
- object = rb_funcall(rb_cTime, id_parse, 1, object);
512
- }
513
-
514
- switch (TYPE(object)) {
515
- case T_FIXNUM:
516
- case T_BIGNUM:
517
- sec = NUM2LL(object);
518
- usec = 0;
519
- break;
520
- case T_FLOAT:
521
- rb_sec = rb_funcall(object, rb_intern("to_i"), 0);
522
- rb_usec = rb_funcall(object, rb_intern("remainder"), 1,
523
- INT2NUM(1));
504
+ case GRN_DB_UINT32:
505
+ value.uint32_value = NUM2UINT(object);
506
+ string = (const char *)&(value.uint32_value);
507
+ size = sizeof(value.uint32_value);
508
+ break;
509
+ case GRN_DB_INT64:
510
+ value.int64_value = NUM2LL(object);
511
+ string = (const char *)&(value.int64_value);
512
+ size = sizeof(value.int64_value);
513
+ break;
514
+ case GRN_DB_UINT64:
515
+ value.uint64_value = NUM2ULL(object);
516
+ string = (const char *)&(value.uint64_value);
517
+ size = sizeof(value.uint64_value);
518
+ break;
519
+ case GRN_DB_FLOAT:
520
+ value.double_value = NUM2DBL(object);
521
+ string = (const char *)&(value.double_value);
522
+ size = sizeof(value.double_value);
523
+ break;
524
+ case GRN_DB_TIME: {
525
+ VALUE rb_sec, rb_usec;
526
+ int64_t sec;
527
+ int32_t usec;
528
+
529
+ if (string_p) {
530
+ ID id_parse;
531
+ CONST_ID(id_parse, "parse");
532
+ object = rb_funcall(rb_cTime, id_parse, 1, object);
533
+ }
524
534
 
525
- sec = NUM2LL(rb_sec);
526
- usec = (int32_t)(NUM2DBL(rb_usec) * 1000000);
527
- break;
528
- case T_NIL:
529
- sec = 0;
530
- usec = 0;
531
- break;
532
- default:
533
- sec = NUM2LL(rb_funcall(object, rb_intern("to_i"), 0));
534
- usec = NUM2INT(rb_funcall(object, rb_intern("usec"), 0));
535
- break;
536
- }
535
+ switch (TYPE(object)) {
536
+ case T_FIXNUM:
537
+ case T_BIGNUM:
538
+ sec = NUM2LL(object);
539
+ usec = 0;
540
+ break;
541
+ case T_FLOAT:
542
+ rb_sec = rb_funcall(object, rb_intern("to_i"), 0);
543
+ rb_usec = rb_funcall(object, rb_intern("remainder"), 1,
544
+ INT2NUM(1));
537
545
 
538
- time_value = GRN_TIME_PACK(sec, usec);
546
+ sec = NUM2LL(rb_sec);
547
+ usec = (int32_t)(NUM2DBL(rb_usec) * 1000000);
548
+ break;
549
+ case T_NIL:
550
+ sec = 0;
551
+ usec = 0;
552
+ break;
553
+ default:
554
+ sec = NUM2LL(rb_funcall(object, rb_intern("to_i"), 0));
555
+ usec = NUM2INT(rb_funcall(object, rb_intern("usec"), 0));
556
+ break;
539
557
  }
540
- string = (const char *)&time_value;
541
- size = sizeof(time_value);
558
+
559
+ value.time_value = GRN_TIME_PACK(sec, usec);
560
+ string = (const char *)&(value.time_value);
561
+ size = sizeof(value.time_value);
542
562
  break;
543
- case GRN_DB_SHORT_TEXT:
544
- case GRN_DB_TEXT:
545
- case GRN_DB_LONG_TEXT:
563
+ }
564
+ case GRN_DB_SHORT_TEXT:
565
+ case GRN_DB_TEXT:
566
+ case GRN_DB_LONG_TEXT:
546
567
  string = StringValuePtr(object);
547
568
  size = RSTRING_LEN(object);
548
569
  range = grn_obj_get_range(context, type);
@@ -552,44 +573,43 @@ rb_grn_bulk_from_ruby_object_with_type (VALUE object, grn_ctx *context,
552
573
  size, range);
553
574
  flags |= GRN_OBJ_DO_SHALLOW_COPY;
554
575
  break;
555
- case GRN_DB_TOKYO_GEO_POINT:
556
- case GRN_DB_WGS84_GEO_POINT:
557
- {
558
- VALUE rb_geo_point;
559
- VALUE rb_latitude, rb_longitude;
560
- if (type_id == GRN_DB_TOKYO_GEO_POINT) {
561
- rb_geo_point = rb_funcall(rb_cGrnTokyoGeoPoint,
562
- rb_intern("new"), 1, object);
563
- } else {
564
- rb_geo_point = rb_funcall(rb_cGrnWGS84GeoPoint,
565
- rb_intern("new"), 1, object);
566
- }
567
- rb_geo_point = rb_funcall(rb_geo_point, rb_intern("to_msec"), 0);
568
- rb_latitude = rb_funcall(rb_geo_point, rb_intern("latitude"), 0);
569
- rb_longitude = rb_funcall(rb_geo_point, rb_intern("longitude"), 0);
570
- geo_point_value.latitude = NUM2INT(rb_latitude);
571
- geo_point_value.longitude = NUM2INT(rb_longitude);
572
- string = (const char *)&geo_point_value;
573
- size = sizeof(geo_point_value);
576
+ case GRN_DB_TOKYO_GEO_POINT:
577
+ case GRN_DB_WGS84_GEO_POINT: {
578
+ VALUE rb_geo_point;
579
+ VALUE rb_latitude, rb_longitude;
580
+ if (type_id == GRN_DB_TOKYO_GEO_POINT) {
581
+ rb_geo_point = rb_funcall(rb_cGrnTokyoGeoPoint,
582
+ rb_intern("new"), 1, object);
583
+ } else {
584
+ rb_geo_point = rb_funcall(rb_cGrnWGS84GeoPoint,
585
+ rb_intern("new"), 1, object);
574
586
  }
587
+ rb_geo_point = rb_funcall(rb_geo_point, rb_intern("to_msec"), 0);
588
+ rb_latitude = rb_funcall(rb_geo_point, rb_intern("latitude"), 0);
589
+ rb_longitude = rb_funcall(rb_geo_point, rb_intern("longitude"), 0);
590
+ value.geo_point_value.latitude = NUM2INT(rb_latitude);
591
+ value.geo_point_value.longitude = NUM2INT(rb_longitude);
592
+ string = (const char *)&(value.geo_point_value);
593
+ size = sizeof(value.geo_point_value);
575
594
  break;
576
- case GRN_DB_VOID:
577
- case GRN_DB_DELIMIT:
578
- case GRN_DB_UNIGRAM:
579
- case GRN_DB_BIGRAM:
580
- case GRN_DB_TRIGRAM:
581
- case GRN_DB_MECAB:
595
+ }
596
+ case GRN_DB_VOID:
597
+ case GRN_DB_DELIMIT:
598
+ case GRN_DB_UNIGRAM:
599
+ case GRN_DB_BIGRAM:
600
+ case GRN_DB_TRIGRAM:
601
+ case GRN_DB_MECAB:
582
602
  rb_type_object = GRNOBJECT2RVAL(Qnil, context, type, GRN_FALSE);
583
603
  rb_raise(rb_eArgError,
584
604
  "unbulkable type: %s",
585
605
  rb_grn_inspect(rb_type_object));
586
606
  break;
587
- default:
607
+ default:
588
608
  if (table_type_p &&
589
609
  (NIL_P(object) || (string_p && RSTRING_LEN(object) == 0))) {
590
- record_id = GRN_ID_NIL;
591
- string = (const char *)&record_id;
592
- size = sizeof(record_id);
610
+ value.record_id = GRN_ID_NIL;
611
+ string = (const char *)&(value.record_id);
612
+ size = sizeof(value.record_id);
593
613
  if (bulk && bulk->header.domain != type_id) {
594
614
  grn_obj_reinit(context, bulk, type_id, 0);
595
615
  }
@@ -743,50 +763,48 @@ rb_grn_uvector_to_ruby_object (grn_ctx *context, grn_obj *uvector,
743
763
  }
744
764
 
745
765
  switch (range->header.type) {
746
- case GRN_TYPE:
747
- {
748
- const char *current, *end;
749
- grn_id range_id;
750
- grn_obj value;
751
- int value_size;
752
- value_size = grn_obj_get_range(context, range);
753
- array = rb_ary_new();
754
- current = GRN_BULK_HEAD(uvector);
755
- end = GRN_BULK_CURR(uvector);
756
- range_id = grn_obj_id(context, range);
757
- GRN_OBJ_INIT(&value, GRN_BULK, GRN_OBJ_DO_SHALLOW_COPY, range_id);
758
- while (current < end) {
759
- VALUE rb_value;
760
- GRN_TEXT_SET(context, &value, current, value_size);
761
- rb_value = GRNBULK2RVAL(context, &value, range, related_object);
762
- rb_ary_push(array, rb_value);
763
- current += value_size;
764
- }
765
- GRN_OBJ_FIN(context, &value);
766
+ case GRN_TYPE: {
767
+ const char *current, *end;
768
+ grn_id range_id;
769
+ grn_obj value;
770
+ int value_size;
771
+ value_size = grn_obj_get_range(context, range);
772
+ array = rb_ary_new();
773
+ current = GRN_BULK_HEAD(uvector);
774
+ end = GRN_BULK_CURR(uvector);
775
+ range_id = grn_obj_id(context, range);
776
+ GRN_OBJ_INIT(&value, GRN_BULK, GRN_OBJ_DO_SHALLOW_COPY, range_id);
777
+ while (current < end) {
778
+ VALUE rb_value;
779
+ GRN_TEXT_SET(context, &value, current, value_size);
780
+ rb_value = GRNBULK2RVAL(context, &value, range, related_object);
781
+ rb_ary_push(array, rb_value);
782
+ current += value_size;
766
783
  }
784
+ GRN_OBJ_FIN(context, &value);
767
785
  break;
768
- case GRN_TABLE_HASH_KEY:
769
- case GRN_TABLE_PAT_KEY:
770
- case GRN_TABLE_DAT_KEY:
771
- case GRN_TABLE_NO_KEY:
772
- {
773
- grn_id *current, *end;
774
- VALUE rb_range = Qnil;
775
- array = rb_ary_new();
776
- rb_range = GRNTABLE2RVAL(context, range, GRN_FALSE);
777
- current = (grn_id *)GRN_BULK_HEAD(uvector);
778
- end = (grn_id *)GRN_BULK_CURR(uvector);
779
- while (current < end) {
780
- VALUE record = Qnil;
781
- if (*current != GRN_ID_NIL) {
782
- record = rb_grn_record_new(rb_range, *current, Qnil);
783
- }
784
- rb_ary_push(array, record);
785
- current++;
786
+ }
787
+ case GRN_TABLE_HASH_KEY:
788
+ case GRN_TABLE_PAT_KEY:
789
+ case GRN_TABLE_DAT_KEY:
790
+ case GRN_TABLE_NO_KEY: {
791
+ grn_id *current, *end;
792
+ VALUE rb_range = Qnil;
793
+ array = rb_ary_new();
794
+ rb_range = GRNTABLE2RVAL(context, range, GRN_FALSE);
795
+ current = (grn_id *)GRN_BULK_HEAD(uvector);
796
+ end = (grn_id *)GRN_BULK_CURR(uvector);
797
+ while (current < end) {
798
+ VALUE record = Qnil;
799
+ if (*current != GRN_ID_NIL) {
800
+ record = rb_grn_record_new(rb_range, *current, Qnil);
786
801
  }
802
+ rb_ary_push(array, record);
803
+ current++;
787
804
  }
788
805
  break;
789
- default:
806
+ }
807
+ default:
790
808
  rb_raise(rb_eTypeError,
791
809
  "unknown range uvector can't be converted: %s(%#x): <%s>",
792
810
  rb_grn_inspect_type(range->header.type),
@@ -864,10 +882,10 @@ rb_grn_uvector_from_ruby_object_reference (UVectorFromRubyData *data)
864
882
 
865
883
  rb_value = rb_values[i];
866
884
  switch (TYPE(rb_value)) {
867
- case T_FIXNUM:
885
+ case T_FIXNUM:
868
886
  id = NUM2UINT(rb_value);
869
887
  break;
870
- default:
888
+ default:
871
889
  CONST_ID(id_record_raw_id, "record_raw_id");
872
890
  if (rb_respond_to(rb_value, id_record_raw_id)) {
873
891
  id = NUM2UINT(rb_funcall(rb_value, id_record_raw_id, 0));
@@ -897,16 +915,16 @@ rb_grn_uvector_from_ruby_object_body (VALUE user_data)
897
915
 
898
916
  domain = data->domain;
899
917
  switch (domain->header.type) {
900
- case GRN_TYPE:
918
+ case GRN_TYPE:
901
919
  rb_grn_uvector_from_ruby_object_type(data);
902
920
  break;
903
- case GRN_TABLE_HASH_KEY:
904
- case GRN_TABLE_PAT_KEY:
905
- case GRN_TABLE_DAT_KEY:
906
- case GRN_TABLE_NO_KEY:
921
+ case GRN_TABLE_HASH_KEY:
922
+ case GRN_TABLE_PAT_KEY:
923
+ case GRN_TABLE_DAT_KEY:
924
+ case GRN_TABLE_NO_KEY:
907
925
  rb_grn_uvector_from_ruby_object_reference(data);
908
926
  break;
909
- default:
927
+ default:
910
928
  rb_raise(rb_eTypeError,
911
929
  "can't convert to unknown domain uvector: %s(%#x): <%s>",
912
930
  rb_grn_inspect_type(domain->header.type),
@@ -975,23 +993,23 @@ rb_grn_value_to_ruby_object (grn_ctx *context,
975
993
  return Qnil;
976
994
 
977
995
  switch (value->header.type) {
978
- case GRN_VOID:
996
+ case GRN_VOID:
979
997
  return Qnil;
980
998
  break;
981
- case GRN_BULK:
999
+ case GRN_BULK:
982
1000
  if (GRN_BULK_EMPTYP(value))
983
1001
  return Qnil;
984
1002
  if (value->header.domain == GRN_ID_NIL && range)
985
1003
  value->header.domain = grn_obj_id(context, range);
986
1004
  return GRNBULK2RVAL(context, value, range, related_object);
987
1005
  break;
988
- case GRN_UVECTOR:
1006
+ case GRN_UVECTOR:
989
1007
  return GRNUVECTOR2RVAL(context, value, range, related_object);
990
1008
  break;
991
- case GRN_VECTOR:
1009
+ case GRN_VECTOR:
992
1010
  return GRNVECTOR2RVAL(context, value);
993
1011
  break;
994
- default:
1012
+ default:
995
1013
  rb_raise(rb_eGrnError,
996
1014
  "unsupported value type: %s(%#x): %s",
997
1015
  rb_grn_inspect_type(value->header.type),
@@ -1065,16 +1083,16 @@ rb_grn_key_from_ruby_object (VALUE rb_key, grn_ctx *context,
1065
1083
  return RVAL2GRNBULK(rb_key, context, key);
1066
1084
 
1067
1085
  switch (domain->header.type) {
1068
- case GRN_TYPE:
1086
+ case GRN_TYPE:
1069
1087
  return RVAL2GRNBULK_WITH_TYPE(rb_key, context, key, domain_id, domain);
1070
1088
  break;
1071
- case GRN_TABLE_HASH_KEY:
1072
- case GRN_TABLE_PAT_KEY:
1073
- case GRN_TABLE_DAT_KEY:
1074
- case GRN_TABLE_NO_KEY:
1089
+ case GRN_TABLE_HASH_KEY:
1090
+ case GRN_TABLE_PAT_KEY:
1091
+ case GRN_TABLE_DAT_KEY:
1092
+ case GRN_TABLE_NO_KEY:
1075
1093
  id = RVAL2GRNID(rb_key, context, domain, related_object);
1076
1094
  break;
1077
- default:
1095
+ default:
1078
1096
  if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_key, rb_cInteger)))
1079
1097
  rb_raise(rb_eGrnError,
1080
1098
  "should be unsigned integer: <%s>: <%s>",
@@ -1144,42 +1162,42 @@ rb_grn_obj_to_ruby_object (VALUE klass, grn_ctx *context,
1144
1162
  /* klass = GRNOBJECT2RCLASS(obj); */
1145
1163
 
1146
1164
  switch (obj->header.type) {
1147
- case GRN_VOID:
1165
+ case GRN_VOID:
1148
1166
  if (GRN_BULK_VSIZE(obj) > 0)
1149
1167
  return rb_str_new(GRN_BULK_HEAD(obj), GRN_BULK_VSIZE(obj));
1150
1168
  else
1151
1169
  return Qnil;
1152
1170
  break;
1153
- case GRN_BULK:
1171
+ case GRN_BULK:
1154
1172
  return GRNBULK2RVAL(context, obj, NULL, related_object);
1155
1173
  break;
1156
- /* case GRN_PTR: */
1157
- /* case GRN_UVECTOR: */
1158
- /* case GRN_PVECTOR: */
1159
- case GRN_VECTOR:
1174
+ /* case GRN_PTR: */
1175
+ /* case GRN_UVECTOR: */
1176
+ /* case GRN_PVECTOR: */
1177
+ case GRN_VECTOR:
1160
1178
  return GRNVECTOR2RVAL(context, obj);
1161
1179
  break;
1162
- /* case GRN_MSG: */
1163
- /* case GRN_QUERY: */
1164
- /* case GRN_ACCESSOR: */
1165
- /* case GRN_SNIP: */
1166
- /* case GRN_PATSNIP: */
1167
- /* case GRN_CURSOR_TABLE_HASH_KEY: */
1168
- /* case GRN_CURSOR_TABLE_PAT_KEY: */
1169
- /* case GRN_CURSOR_TABLE_NO_KEY: */
1170
- /* case GRN_CURSOR_COLUMN_INDEX: */
1171
- /* case GRN_TYPE: */
1172
- /* case GRN_PROC: */
1173
- /* case GRN_EXPR: */
1174
- /* case GRN_TABLE_HASH_KEY: */
1175
- /* case GRN_TABLE_PAT_KEY: */
1176
- /* case GRN_TABLE_DAT_KEY: */
1177
- /* case GRN_TABLE_NO_KEY: */
1178
- /* case GRN_DB: */
1179
- /* case GRN_COLUMN_FIX_SIZE: */
1180
- /* case GRN_COLUMN_VAR_SIZE: */
1181
- /* case GRN_COLUMN_INDEX: */
1182
- default:
1180
+ /* case GRN_MSG: */
1181
+ /* case GRN_QUERY: */
1182
+ /* case GRN_ACCESSOR: */
1183
+ /* case GRN_SNIP: */
1184
+ /* case GRN_PATSNIP: */
1185
+ /* case GRN_CURSOR_TABLE_HASH_KEY: */
1186
+ /* case GRN_CURSOR_TABLE_PAT_KEY: */
1187
+ /* case GRN_CURSOR_TABLE_NO_KEY: */
1188
+ /* case GRN_CURSOR_COLUMN_INDEX: */
1189
+ /* case GRN_TYPE: */
1190
+ /* case GRN_PROC: */
1191
+ /* case GRN_EXPR: */
1192
+ /* case GRN_TABLE_HASH_KEY: */
1193
+ /* case GRN_TABLE_PAT_KEY: */
1194
+ /* case GRN_TABLE_DAT_KEY: */
1195
+ /* case GRN_TABLE_NO_KEY: */
1196
+ /* case GRN_DB: */
1197
+ /* case GRN_COLUMN_FIX_SIZE: */
1198
+ /* case GRN_COLUMN_VAR_SIZE: */
1199
+ /* case GRN_COLUMN_INDEX: */
1200
+ default:
1183
1201
  rb_raise(rb_eTypeError,
1184
1202
  "unsupported groonga object: %s(%#x): <%s>",
1185
1203
  rb_grn_inspect_type(obj->header.type),