rroonga 5.1.1 → 6.0.0

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.
@@ -1,6 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
3
  Copyright (C) 2015-2016 Kouhei Sutou <kou@clear-code.com>
4
+ Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
4
5
 
5
6
  This library is free software; you can redistribute it and/or
6
7
  modify it under the terms of the GNU Lesser General Public
@@ -73,11 +74,9 @@ rb_grn_config_get (VALUE self, VALUE rb_key)
73
74
 
74
75
  {
75
76
  grn_rc rc;
76
- /* TODO: Replace it with grn_config_get() after Groonga 5.1.2
77
- * is released.*/
78
- rc = grn_conf_get(context,
79
- key, key_size,
80
- &value, &value_size);
77
+ rc = grn_config_get(context,
78
+ key, key_size,
79
+ &value, &value_size);
81
80
  rb_grn_context_check(context, self);
82
81
  rb_grn_rc_check(rc, self);
83
82
  }
@@ -123,11 +122,9 @@ rb_grn_config_set (VALUE self, VALUE rb_key, VALUE rb_value)
123
122
 
124
123
  {
125
124
  grn_rc rc;
126
- /* TODO: Replace it with grn_config_set() after Groonga 5.1.2
127
- * is released.*/
128
- rc = grn_conf_set(context,
129
- key, key_size,
130
- value, value_size);
125
+ rc = grn_config_set(context,
126
+ key, key_size,
127
+ value, value_size);
131
128
  rb_grn_context_check(context, self);
132
129
  rb_grn_rc_check(rc, self);
133
130
  }
@@ -135,16 +132,140 @@ rb_grn_config_set (VALUE self, VALUE rb_key, VALUE rb_value)
135
132
  return rb_value_original;
136
133
  }
137
134
 
135
+ /*
136
+ * Deletes a configuration for key.
137
+ *
138
+ * @overload delete(key)
139
+ * @param [String] key The key.
140
+ *
141
+ * @since 6.0.0
142
+ */
143
+ static VALUE
144
+ rb_grn_config_delete (VALUE self, VALUE rb_key)
145
+ {
146
+ VALUE rb_context;
147
+ grn_ctx *context;
148
+ const char *key;
149
+ int key_size;
150
+
151
+ rb_context = rb_iv_get(self, "@context");
152
+ context = rb_grn_context_ensure(&rb_context);
153
+
154
+ rb_key = rb_grn_convert_to_string(rb_key);
155
+ key = RSTRING_PTR(rb_key);
156
+ key_size = RSTRING_LEN(rb_key);
157
+
158
+ {
159
+ grn_rc rc;
160
+ rc = grn_config_delete(context,
161
+ key, key_size);
162
+ rb_grn_context_check(context, self);
163
+ rb_grn_rc_check(rc, self);
164
+ }
165
+
166
+ return Qnil;
167
+ }
168
+
169
+ typedef struct {
170
+ grn_ctx *context;
171
+ grn_obj *cursor;
172
+ } RbGrnConfigEachData;
173
+
174
+ static VALUE
175
+ rb_grn_config_each_body (VALUE user_data)
176
+ {
177
+ RbGrnConfigEachData *data = (RbGrnConfigEachData *)user_data;
178
+ grn_ctx *context;
179
+ grn_obj *cursor;
180
+
181
+ context = data->context;
182
+ cursor = data->cursor;
183
+ while (grn_config_cursor_next(context, cursor)) {
184
+ const char *key;
185
+ uint32_t key_size;
186
+ VALUE rb_key;
187
+ const char *value;
188
+ uint32_t value_size;
189
+ VALUE rb_value;
190
+
191
+ key_size = grn_config_cursor_get_key(context, cursor, &key);
192
+ rb_key = rb_grn_context_rb_string_new(context, key, key_size);
193
+ value_size = grn_config_cursor_get_value(context, cursor, &value);
194
+ rb_value = rb_grn_context_rb_string_new(context, value, value_size);
195
+
196
+ rb_yield_values(2, rb_key, rb_value);
197
+ }
198
+
199
+ return Qnil;
200
+ }
201
+
202
+ static VALUE
203
+ rb_grn_config_each_ensure (VALUE user_data)
204
+ {
205
+ RbGrnConfigEachData *data = (RbGrnConfigEachData *)user_data;
206
+
207
+ grn_obj_close(data->context, data->cursor);
208
+
209
+ return Qnil;
210
+ }
211
+
212
+ /*
213
+ * Passes all key/value of the config to block in order.
214
+ *
215
+ * @example Shows all keys and all values of the config
216
+ * context.config["rroonga.key1"] = "value1"
217
+ * context.config["rroonga.key2"] = "value2"
218
+ * keys = []
219
+ * values = []
220
+ * context.config.each do |key, value|
221
+ * keys << key
222
+ * values << value
223
+ * end
224
+ * p keys # => ["rroonga.key1", "rroonga.key2"]
225
+ * p values # => ["value1", "value2"]
226
+ *
227
+ * @overload each
228
+ * @yield [key, value]
229
+ * @yieldparam [String] key The configuration key
230
+ * @yieldparam [String] value The value which is associated with `key`
231
+ *
232
+ * @since 6.0.0
233
+ */
234
+ static VALUE
235
+ rb_grn_config_each (VALUE self)
236
+ {
237
+ VALUE rb_context;
238
+ RbGrnConfigEachData data;
239
+
240
+ RETURN_ENUMERATOR(self, 0, NULL);
241
+
242
+ rb_context = rb_iv_get(self, "@context");
243
+ data.context = rb_grn_context_ensure(&rb_context);
244
+
245
+ data.cursor = grn_config_cursor_open(data.context);
246
+ rb_ensure(rb_grn_config_each_body, (VALUE)&data,
247
+ rb_grn_config_each_ensure, (VALUE)&data);
248
+
249
+ return Qnil;
250
+ }
251
+
138
252
  void
139
253
  rb_grn_init_config (VALUE mGrn)
140
254
  {
141
255
  VALUE cGrnConfig;
142
256
 
143
257
  cGrnConfig = rb_define_class_under(mGrn, "Config", rb_cObject);
258
+ /* For backward compatibility. */
144
259
  rb_define_const(mGrn, "Conf", cGrnConfig);
145
260
 
261
+ rb_include_module(cGrnConfig, rb_mEnumerable);
262
+
146
263
  rb_define_method(cGrnConfig, "initialize", rb_grn_config_initialize, 1);
147
264
 
148
265
  rb_define_method(cGrnConfig, "[]", rb_grn_config_get, 1);
149
266
  rb_define_method(cGrnConfig, "[]=", rb_grn_config_set, 2);
267
+
268
+ rb_define_method(cGrnConfig, "delete", rb_grn_config_delete, 1);
269
+
270
+ rb_define_method(cGrnConfig, "each", rb_grn_config_each, 0);
150
271
  }
@@ -302,18 +302,13 @@ rb_grn_context_rb_string_new (grn_ctx *context, const char *string, long length)
302
302
  {
303
303
  if (length < 0)
304
304
  length = strlen(string);
305
- #ifdef HAVE_RUBY_ENCODING_H
306
305
  return rb_enc_str_new(string, length,
307
306
  rb_grn_encoding_to_ruby_encoding(context->encoding));
308
- #else
309
- return rb_str_new(string, length);
310
- #endif
311
307
  }
312
308
 
313
309
  VALUE
314
310
  rb_grn_context_rb_string_encode (grn_ctx *context, VALUE rb_string)
315
311
  {
316
- #ifdef HAVE_RUBY_ENCODING_H
317
312
  int index, to_index;
318
313
  rb_encoding *encoding, *to_encoding;
319
314
  grn_encoding context_encoding;
@@ -339,7 +334,6 @@ rb_grn_context_rb_string_encode (grn_ctx *context, VALUE rb_string)
339
334
 
340
335
  rb_string = rb_str_encode(rb_string, rb_enc_from_encoding(to_encoding),
341
336
  0, Qnil);
342
- #endif
343
337
  return rb_string;
344
338
  }
345
339
 
@@ -601,14 +595,10 @@ rb_grn_context_set_encoding (VALUE self, VALUE rb_encoding)
601
595
  static VALUE
602
596
  rb_grn_context_get_ruby_encoding (VALUE self)
603
597
  {
604
- #ifdef HAVE_RUBY_ENCODING_H
605
598
  grn_encoding encoding;
606
599
 
607
600
  encoding = GRN_CTX_GET_ENCODING(SELF(self));
608
601
  return rb_grn_encoding_to_ruby_encoding_object(encoding);
609
- #else
610
- return Qnil;
611
- #endif
612
602
  }
613
603
 
614
604
  /*
@@ -148,7 +148,6 @@ rb_grn_encoding_to_ruby_object (grn_encoding encoding)
148
148
  return rb_encoding;
149
149
  }
150
150
 
151
- #ifdef HAVE_RUBY_ENCODING_H
152
151
  rb_encoding *
153
152
  rb_grn_encoding_to_ruby_encoding (grn_encoding encoding)
154
153
  {
@@ -190,7 +189,6 @@ rb_grn_encoding_to_ruby_encoding_object (grn_encoding encoding)
190
189
  rb_encoding *rb_encoding = rb_grn_encoding_to_ruby_encoding(encoding);
191
190
  return rb_enc_from_encoding(rb_encoding);
192
191
  }
193
- #endif
194
192
 
195
193
  /*
196
194
  * デフォルトのエンコーディングを返す。
@@ -203,6 +203,43 @@ rb_grn_expression_define_variable (int argc, VALUE *argv, VALUE self)
203
203
  return rb_variable;
204
204
  }
205
205
 
206
+ /* TODO: Enable when Groonga 6.0.1 is released. */
207
+ /*
208
+ typedef struct
209
+ {
210
+ grn_ctx *context;
211
+ grn_hash *hash;
212
+ VALUE rb_hash;
213
+ } RbGrnHashFromRubyHashData;
214
+
215
+ static int
216
+ rb_grn_hash_from_ruby_hash_body (VALUE rb_key,
217
+ VALUE rb_value,
218
+ VALUE user_data)
219
+ {
220
+ RbGrnHashFromRubyHashData *data = (RbGrnHashFromRubyHashData *)user_data;
221
+ grn_obj *value;
222
+ int added;
223
+
224
+ rb_key = rb_grn_convert_to_string(rb_key);
225
+
226
+ grn_hash_add(data->context,
227
+ data->hash,
228
+ RSTRING_PTR(rb_key),
229
+ RSTRING_LEN(rb_key),
230
+ (void **)&value,
231
+ &added);
232
+ rb_grn_context_check(data->context, data->rb_hash);
233
+
234
+ if (added) {
235
+ GRN_VOID_INIT(value);
236
+ }
237
+ RVAL2GRNBULK(rb_value, data->context, value);
238
+
239
+ return ST_CONTINUE;
240
+ }
241
+ */
242
+
206
243
  /*
207
244
  * _object_ を追加し、 _n_arguments_ 個の引数を取る _operation_ を追加する。
208
245
  *
@@ -232,9 +269,32 @@ rb_grn_expression_append_object (int argc, VALUE *argv, VALUE self)
232
269
  NULL, NULL,
233
270
  NULL, NULL, NULL);
234
271
 
235
- object = RVAL2GRNOBJECT(rb_object, &context);
236
- grn_expr_append_obj(context, expression, object,
237
- operation, n_arguments);
272
+ /* TODO: Enable when Groonga 6.0.1 is released. */
273
+ /*
274
+ if (RB_TYPE_P(rb_object, RUBY_T_HASH)) {
275
+ RbGrnHashFromRubyHashData data;
276
+ data.context = context;
277
+ data.hash = grn_hash_create(context, NULL,
278
+ GRN_TABLE_MAX_KEY_SIZE,
279
+ sizeof(grn_obj),
280
+ GRN_OBJ_KEY_VAR_SIZE |
281
+ GRN_OBJ_TEMPORARY |
282
+ GRN_HASH_TINY);
283
+ grn_expr_take_obj(context, expression, (grn_obj *)(data.hash));
284
+ data.rb_hash = rb_object;
285
+ rb_hash_foreach(rb_object,
286
+ rb_grn_hash_from_ruby_hash_body,
287
+ (VALUE)&data);
288
+ grn_expr_append_obj(context, expression, (grn_obj *)(data.hash),
289
+ operation, n_arguments);
290
+ } else {
291
+ */
292
+ object = RVAL2GRNOBJECT(rb_object, &context);
293
+ grn_expr_append_obj(context, expression, object,
294
+ operation, n_arguments);
295
+ /*
296
+ }
297
+ */
238
298
  rb_grn_context_check(context, self);
239
299
  rb_ary_push(rb_iv_get(self, "@objects"), rb_object);
240
300
 
@@ -0,0 +1,34 @@
1
+ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
+ /*
3
+ Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
4
+
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License version 2.1 as published by the Free Software Foundation.
8
+
9
+ This library is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public
15
+ License along with this library; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+ #include "rb-grn.h"
20
+
21
+ VALUE rb_cGrnIndex;
22
+
23
+ VALUE
24
+ rb_grn_index_new (VALUE rb_index_column, VALUE rb_section)
25
+ {
26
+ return rb_funcall(rb_cGrnIndex, rb_intern("new"), 2,
27
+ rb_index_column, rb_section);
28
+ }
29
+
30
+ void
31
+ rb_grn_init_index (VALUE mGrn)
32
+ {
33
+ rb_cGrnIndex = rb_const_get(mGrn, rb_intern("Index"));
34
+ }
@@ -93,7 +93,7 @@ rb_grn_object_unbind (RbGrnObject *rb_grn_object)
93
93
  {
94
94
  debug("unbind: %p:%p:%p %s(%#x)\n",
95
95
  rb_grn_object->context, rb_grn_object->object, rb_grn_object,
96
- rb_grn_inspect_type(rb_grn_object->object->header.type),
96
+ grn_obj_type_to_string(rb_grn_object->object->header.type),
97
97
  rb_grn_object->object->header.type);
98
98
 
99
99
  rb_grn_object->rb_grn_context = NULL;
@@ -116,7 +116,7 @@ rb_grn_object_run_finalizer (grn_ctx *context, grn_obj *grn_object,
116
116
  context, grn_object, rb_grn_object,
117
117
  rb_grn_object->context, rb_grn_object->object,
118
118
  rb_grn_object->rb_grn_context,
119
- rb_grn_inspect_type(grn_object->header.type),
119
+ grn_obj_type_to_string(grn_object->header.type),
120
120
  grn_object->header.type);
121
121
 
122
122
  rb_grn_context = rb_grn_object->rb_grn_context;
@@ -173,7 +173,7 @@ rb_grn_object_run_finalizer (grn_ctx *context, grn_obj *grn_object,
173
173
  default:
174
174
  rb_raise(rb_eTypeError,
175
175
  "unsupported Groonga object type for finalizer: %s(%#x)",
176
- rb_grn_inspect_type(grn_object->header.type),
176
+ grn_obj_type_to_string(grn_object->header.type),
177
177
  grn_object->header.type);
178
178
  break;
179
179
  }
@@ -217,7 +217,7 @@ rb_grn_object_free (RbGrnObject *rb_grn_object)
217
217
  user_data = grn_obj_user_data(context, grn_object);
218
218
  }
219
219
  debug("type: %s(%#x); need_close: %d; user_data: %p; ptr: %p\n",
220
- rb_grn_inspect_type(grn_object->header.type),
220
+ grn_obj_type_to_string(grn_object->header.type),
221
221
  grn_object->header.type,
222
222
  rb_grn_object->need_close,
223
223
  user_data,
@@ -362,7 +362,7 @@ rb_grn_object_bind_common (VALUE klass, VALUE self, VALUE rb_context,
362
362
 
363
363
  debug("bind: %p:%p:%p %s(%#x)\n",
364
364
  context, object, rb_grn_object,
365
- rb_grn_inspect_type(object->header.type),
365
+ grn_obj_type_to_string(object->header.type),
366
366
  object->header.type);
367
367
 
368
368
  Data_Get_Struct(rb_context, RbGrnContext, rb_grn_context);
@@ -378,7 +378,7 @@ rb_grn_object_bind_common (VALUE klass, VALUE self, VALUE rb_context,
378
378
  if (user_data) {
379
379
  debug("set-finalizer: %p:%p:%p %s(%#x)\n",
380
380
  context, object, rb_grn_object,
381
- rb_grn_inspect_type(object->header.type),
381
+ grn_obj_type_to_string(object->header.type),
382
382
  object->header.type);
383
383
  user_data->ptr = rb_grn_object;
384
384
  grn_obj_set_finalizer(context, object, rb_grn_object_finalizer);
@@ -386,7 +386,7 @@ rb_grn_object_bind_common (VALUE klass, VALUE self, VALUE rb_context,
386
386
  } else if (object->header.type == GRN_ACCESSOR) {
387
387
  debug("set-finalizer(implicit): %p:%p:%p %s(%#x)\n",
388
388
  context, object, rb_grn_object,
389
- rb_grn_inspect_type(object->header.type),
389
+ grn_obj_type_to_string(object->header.type),
390
390
  object->header.type);
391
391
  rb_grn_object->have_finalizer = GRN_TRUE;
392
392
  }
@@ -500,7 +500,7 @@ rb_grn_object_assign (VALUE klass, VALUE self, VALUE rb_context,
500
500
  } else {
501
501
  rb_raise(rb_eTypeError,
502
502
  "unsupported Groonga object type for assignment: %s(%#x)",
503
- rb_grn_inspect_type(object->header.type),
503
+ grn_obj_type_to_string(object->header.type),
504
504
  object->header.type);
505
505
  }
506
506
 
@@ -508,7 +508,7 @@ rb_grn_object_assign (VALUE klass, VALUE self, VALUE rb_context,
508
508
 
509
509
  debug("assign: %p:%p:%p %s(%#x)\n",
510
510
  context, object, rb_grn_object,
511
- rb_grn_inspect_type(object->header.type), object->header.type);
511
+ grn_obj_type_to_string(object->header.type), object->header.type);
512
512
  }
513
513
 
514
514
  void
@@ -545,7 +545,7 @@ rb_grn_named_object_set_name (RbGrnNamedObject *rb_grn_named_object,
545
545
  RB_GRN_OBJECT(rb_grn_named_object)->context,
546
546
  RB_GRN_OBJECT(rb_grn_named_object)->object,
547
547
  rb_grn_named_object,
548
- rb_grn_inspect_type(RB_GRN_OBJECT(rb_grn_named_object)->header.type),
548
+ grn_obj_type_to_string(RB_GRN_OBJECT(rb_grn_named_object)->header.type),
549
549
  RB_GRN_OBJECT(rb_grn_named_object)->object->header.type,
550
550
  name_size, name);
551
551
  }
@@ -1,6 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
4
+ Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
4
5
 
5
6
  This library is free software; you can redistribute it and/or
6
7
  modify it under the terms of the GNU Lesser General Public
@@ -224,6 +225,8 @@ rb_grn_operator_from_ruby_object (VALUE rb_operator)
224
225
  operator = GRN_OP_JSON_PUT;
225
226
  } else if (rb_grn_equal_option(rb_operator, "regexp")) {
226
227
  operator = GRN_OP_REGEXP;
228
+ } else if (rb_grn_equal_option(rb_operator, "fuzzy")) {
229
+ operator = GRN_OP_FUZZY;
227
230
  } else {
228
231
  rb_raise(rb_eArgError,
229
232
  "operator should be one of "
@@ -635,6 +638,10 @@ rb_grn_init_operator (VALUE mGrn)
635
638
  rb_funcall(rb_cGrnRegexpOperator, rb_intern("new"), 2,
636
639
  rb_str_new_cstr("regexp"),
637
640
  UINT2NUM(GRN_OP_REGEXP)));
641
+ rb_define_const(rb_cGrnOperator, "FUZZY",
642
+ rb_funcall(rb_cGrnOperator, rb_intern("new"), 2,
643
+ rb_str_new_cstr("fuzzy"),
644
+ UINT2NUM(GRN_OP_FUZZY)));
638
645
 
639
646
 
640
647
  /*
@@ -1,6 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
3
  Copyright (C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
4
+ Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
4
5
 
5
6
  This library is free software; you can redistribute it and/or
6
7
  modify it under the terms of the GNU Lesser General Public
@@ -205,6 +206,42 @@ rb_grn_plugin_s_ruby_suffix (VALUE klass)
205
206
  return rb_str_new_cstr(grn_plugin_get_ruby_suffix());
206
207
  }
207
208
 
209
+ /*
210
+ * Returns the names of loaded plugins.
211
+ *
212
+ * @overload names(options={})
213
+ * @return [Array<String>]
214
+ * @param options [::Hash] The name and value pairs.
215
+ * @option options :context (Groonga::Context.default)
216
+ * The context which is bound to database.
217
+ *
218
+ * @since 6.0.0
219
+ */
220
+ static VALUE
221
+ rb_grn_plugin_s_names (int argc, VALUE *argv, VALUE klass)
222
+ {
223
+ VALUE rb_options, rb_context, rb_names;
224
+ grn_ctx *context;
225
+ grn_obj names;
226
+
227
+ rb_scan_args(argc, argv, "01", &rb_options);
228
+ rb_grn_scan_options(rb_options,
229
+ "context", &rb_context,
230
+ NULL);
231
+ if (NIL_P(rb_context)) {
232
+ rb_context = rb_grn_context_get_default();
233
+ }
234
+ context = RVAL2GRNCONTEXT(rb_context);
235
+
236
+ GRN_TEXT_INIT(&names, GRN_OBJ_VECTOR);
237
+ grn_plugin_get_names(context, &names);
238
+ rb_names = GRNVECTOR2RVAL(context, &names);
239
+ GRN_OBJ_FIN(context, &names);
240
+
241
+ rb_grn_context_check(context, rb_ary_new_from_values(argc, argv));
242
+ return rb_names;
243
+ }
244
+
208
245
  void
209
246
  rb_grn_init_plugin (VALUE mGrn)
210
247
  {
@@ -221,4 +258,6 @@ rb_grn_init_plugin (VALUE mGrn)
221
258
  rb_grn_plugin_s_suffix, 0);
222
259
  rb_define_singleton_method(cGrnPlugin, "ruby_suffix",
223
260
  rb_grn_plugin_s_ruby_suffix, 0);
261
+ rb_define_singleton_method(cGrnPlugin, "names",
262
+ rb_grn_plugin_s_names, -1);
224
263
  }
@@ -30,67 +30,6 @@ rb_grn_inspect (VALUE object)
30
30
  return StringValueCStr(inspected);
31
31
  }
32
32
 
33
- const char *
34
- rb_grn_inspect_type (unsigned char type)
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
- }
92
- }
93
-
94
33
  void
95
34
  rb_grn_scan_options (VALUE options, ...)
96
35
  {
@@ -903,7 +842,7 @@ rb_grn_uvector_to_ruby_object (grn_ctx *context, grn_obj *uvector,
903
842
  default:
904
843
  rb_raise(rb_eTypeError,
905
844
  "unknown range uvector can't be converted: %s(%#x): <%s>",
906
- rb_grn_inspect_type(range->header.type),
845
+ grn_obj_type_to_string(range->header.type),
907
846
  range->header.type,
908
847
  rb_grn_inspect(related_object));
909
848
  break;
@@ -1023,7 +962,7 @@ rb_grn_uvector_from_ruby_object_body (VALUE user_data)
1023
962
  default:
1024
963
  rb_raise(rb_eTypeError,
1025
964
  "can't convert to unknown domain uvector: %s(%#x): <%s>",
1026
- rb_grn_inspect_type(domain->header.type),
965
+ grn_obj_type_to_string(domain->header.type),
1027
966
  domain->header.type,
1028
967
  rb_grn_inspect(data->related_object));
1029
968
  break;
@@ -1108,7 +1047,7 @@ rb_grn_value_to_ruby_object (grn_ctx *context,
1108
1047
  default:
1109
1048
  rb_raise(rb_eGrnError,
1110
1049
  "unsupported value type: %s(%#x): %s",
1111
- rb_grn_inspect_type(value->header.type),
1050
+ grn_obj_type_to_string(value->header.type),
1112
1051
  value->header.type,
1113
1052
  rb_grn_inspect(related_object));
1114
1053
  break;
@@ -1284,6 +1223,7 @@ rb_grn_obj_to_ruby_object (VALUE klass, grn_ctx *context,
1284
1223
  /* case GRN_CURSOR_TABLE_PAT_KEY: */
1285
1224
  /* case GRN_CURSOR_TABLE_NO_KEY: */
1286
1225
  /* case GRN_CURSOR_COLUMN_INDEX: */
1226
+ /* case GRN_CURSOR_CONFIG: */
1287
1227
  /* case GRN_TYPE: */
1288
1228
  /* case GRN_PROC: */
1289
1229
  /* case GRN_EXPR: */
@@ -1298,7 +1238,7 @@ rb_grn_obj_to_ruby_object (VALUE klass, grn_ctx *context,
1298
1238
  default:
1299
1239
  rb_raise(rb_eTypeError,
1300
1240
  "unsupported groonga object: %s(%#x): <%s>",
1301
- rb_grn_inspect_type(obj->header.type),
1241
+ grn_obj_type_to_string(obj->header.type),
1302
1242
  obj->header.type,
1303
1243
  rb_grn_inspect(related_object));
1304
1244
  break;