rroonga 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/Rakefile +1 -10
  4. data/ext/groonga/extconf.rb +3 -1
  5. data/ext/groonga/rb-grn-array.c +1 -1
  6. data/ext/groonga/rb-grn-column.c +33 -67
  7. data/ext/groonga/rb-grn-context.c +5 -5
  8. data/ext/groonga/rb-grn-database.c +2 -2
  9. data/ext/groonga/rb-grn-double-array-trie.c +4 -2
  10. data/ext/groonga/rb-grn-encoding-support.c +7 -1
  11. data/ext/groonga/rb-grn-equal-operator.c +85 -0
  12. data/ext/groonga/rb-grn-exception.c +17 -0
  13. data/ext/groonga/rb-grn-expression.c +85 -43
  14. data/ext/groonga/rb-grn-greater-equal-operator.c +88 -0
  15. data/ext/groonga/rb-grn-greater-operator.c +85 -0
  16. data/ext/groonga/rb-grn-hash.c +1 -1
  17. data/ext/groonga/rb-grn-index-column.c +150 -11
  18. data/ext/groonga/rb-grn-less-equal-operator.c +88 -0
  19. data/ext/groonga/rb-grn-less-operator.c +85 -0
  20. data/ext/groonga/rb-grn-logger.c +5 -5
  21. data/ext/groonga/rb-grn-match-operator.c +86 -0
  22. data/ext/groonga/rb-grn-normalizer.c +8 -1
  23. data/ext/groonga/rb-grn-not-equal-operator.c +85 -0
  24. data/ext/groonga/rb-grn-object.c +170 -36
  25. data/ext/groonga/rb-grn-operator.c +395 -172
  26. data/ext/groonga/rb-grn-patricia-trie.c +10 -8
  27. data/ext/groonga/rb-grn-plugin.c +51 -3
  28. data/ext/groonga/rb-grn-prefix-operator.c +86 -0
  29. data/ext/groonga/rb-grn-procedure-type.c +4 -0
  30. data/ext/groonga/rb-grn-query-logger.c +4 -4
  31. data/ext/groonga/rb-grn-regexp-operator.c +85 -0
  32. data/ext/groonga/rb-grn-snippet.c +1 -1
  33. data/ext/groonga/rb-grn-table-key-support.c +9 -5
  34. data/ext/groonga/rb-grn-table.c +52 -66
  35. data/ext/groonga/rb-grn-type.c +1 -1
  36. data/ext/groonga/rb-grn-utils.c +22 -3
  37. data/ext/groonga/rb-grn.h +31 -4
  38. data/ext/groonga/rb-groonga.c +9 -9
  39. data/lib/groonga/context.rb +31 -0
  40. data/lib/groonga/expression-builder.rb +14 -1
  41. data/lib/groonga/record.rb +10 -8
  42. data/lib/groonga/schema.rb +3 -1
  43. data/rroonga-build.rb +2 -2
  44. data/rroonga.gemspec +3 -3
  45. data/test/groonga-test-utils.rb +4 -0
  46. data/test/test-column.rb +28 -26
  47. data/test/test-exception.rb +1 -0
  48. data/test/test-expression-builder.rb +83 -1
  49. data/test/test-expression.rb +80 -48
  50. data/test/test-index-column.rb +102 -29
  51. data/test/test-normalizer.rb +35 -29
  52. data/test/test-operator.rb +214 -0
  53. data/test/test-plugin.rb +24 -6
  54. data/test/test-procedure.rb +29 -0
  55. data/test/test-schema-type.rb +14 -0
  56. data/test/test-table-select-mecab.rb +1 -4
  57. data/test/test-table.rb +7 -0
  58. data/test/test-token-regexp.rb +30 -0
  59. data/test/test-type.rb +24 -0
  60. metadata +61 -49
  61. data/doc/text/news.textile +0 -1217
@@ -232,7 +232,7 @@ rb_grn_patricia_trie_s_create (int argc, VALUE *argv, VALUE klass)
232
232
  table = grn_table_create(context, name, name_size, path,
233
233
  flags, key_type, value_type);
234
234
  if (!table)
235
- rb_grn_context_check(context, rb_ary_new4(argc, argv));
235
+ rb_grn_context_check(context, rb_ary_new_from_values(argc, argv));
236
236
  rb_table = GRNOBJECT2RVAL(klass, context, table, GRN_TRUE);
237
237
 
238
238
  if (!NIL_P(rb_default_tokenizer))
@@ -306,6 +306,8 @@ rb_grn_patricia_trie_search (int argc, VALUE *argv, VALUE self)
306
306
  grn_bool search_options_is_set = GRN_FALSE;
307
307
  VALUE rb_key, options, rb_result, rb_operator, rb_type;
308
308
 
309
+ memset(&search_options, 0, sizeof(grn_search_optarg));
310
+
309
311
  rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
310
312
  &key, &domain_id, &domain,
311
313
  NULL, NULL, NULL,
@@ -422,11 +424,11 @@ rb_grn_patricia_trie_scan (VALUE self, VALUE rb_string)
422
424
  term = rb_grn_context_rb_string_new(context,
423
425
  string + hits[i].offset,
424
426
  hits[i].length);
425
- matched_info = rb_ary_new3(4,
426
- record,
427
- term,
428
- UINT2NUM(hits[i].offset),
429
- UINT2NUM(hits[i].length));
427
+ matched_info = rb_ary_new_from_args(4,
428
+ record,
429
+ term,
430
+ UINT2NUM(hits[i].offset),
431
+ UINT2NUM(hits[i].length));
430
432
  if (block_given) {
431
433
  rb_yield(matched_info);
432
434
  } else {
@@ -532,7 +534,7 @@ rb_grn_patricia_trie_open_grn_prefix_cursor (int argc, VALUE *argv, VALUE self,
532
534
  if (!NIL_P(rb_key_bytes) && !NIL_P(rb_key_bits)) {
533
535
  rb_raise(rb_eArgError,
534
536
  "should not specify both :key_bytes and :key_bits once: %s",
535
- rb_grn_inspect(rb_ary_new4(argc, argv)));
537
+ rb_grn_inspect(rb_ary_new_from_values(argc, argv)));
536
538
  } else if (!NIL_P(rb_key_bytes)) {
537
539
  prefix_size = NUM2UINT(rb_key_bytes);
538
540
  } else if (!NIL_P(rb_key_bits)) {
@@ -682,7 +684,7 @@ rb_grn_patricia_trie_open_grn_rk_cursor (int argc, VALUE *argv, VALUE self,
682
684
  if (!NIL_P(rb_key_bytes) && !NIL_P(rb_key_bits)) {
683
685
  rb_raise(rb_eArgError,
684
686
  "should not specify both :key_bytes and :key_bits once: %s",
685
- rb_grn_inspect(rb_ary_new4(argc, argv)));
687
+ rb_grn_inspect(rb_ary_new_from_values(argc, argv)));
686
688
  } else if (!NIL_P(rb_key_bytes)) {
687
689
  prefix_size = NUM2UINT(rb_key_bytes);
688
690
  } else if (!NIL_P(rb_key_bits)) {
@@ -117,7 +117,53 @@ rb_grn_plugin_s_register (int argc, VALUE *argv, VALUE klass)
117
117
  grn_plugin_register_by_path(context, path);
118
118
  }
119
119
 
120
- rb_grn_context_check(context, rb_ary_new4(argc, argv));
120
+ rb_grn_context_check(context, rb_ary_new_from_values(argc, argv));
121
+ return Qnil;
122
+ }
123
+
124
+ /*
125
+ * Unregister a registered plugin.
126
+ *
127
+ * Unregister `name` plugin by name if `name` plugin is installed to
128
+ * plugin directory. You can also specify the path of `name` plugin
129
+ * explicitly.
130
+ *
131
+ * @example Unregister a registerd plugin by name.
132
+ * Groonga::Plugin.register("token_filters/stop_word")
133
+ * Groonga::Plugin.unregister("token_filters/stop_word")
134
+ * @example unregister a registerd plugin by path
135
+ * Groonga::Plugin.register("token_filters/stop_word")
136
+ * Groonga::Plugin.unregister("/usr/local/lib/groonga/plugins/token_filters/stop_word.so")
137
+ * @overload unregister(name, options={})
138
+ * Unregister specified `name` plugin.
139
+ * You can specify the path of plugin explicitly.
140
+ * @param [String] name The name of plugin.
141
+ * @param options [::Hash] The name and value pairs.
142
+ * @option options :context (Groonga::Context.default)
143
+ * The context which is bound to database.
144
+ */
145
+ static VALUE
146
+ rb_grn_plugin_s_unregister (int argc, VALUE *argv, VALUE klass)
147
+ {
148
+ const char *name = NULL;
149
+ VALUE rb_options, rb_name = Qnil, rb_context;
150
+ grn_ctx *context;
151
+
152
+ rb_scan_args(argc, argv, "11", &rb_name, &rb_options);
153
+ rb_grn_scan_options(rb_options,
154
+ "context", &rb_context,
155
+ NULL);
156
+ rb_name = rb_grn_convert_to_string(rb_name);
157
+ name = StringValueCStr(rb_name);
158
+
159
+ if (NIL_P(rb_context)) {
160
+ rb_context = rb_grn_context_get_default();
161
+ }
162
+ context = RVAL2GRNCONTEXT(rb_context);
163
+
164
+ grn_plugin_unregister(context, name);
165
+
166
+ rb_grn_context_check(context, rb_ary_new_from_values(argc, argv));
121
167
  return Qnil;
122
168
  }
123
169
 
@@ -130,7 +176,7 @@ rb_grn_plugin_s_register (int argc, VALUE *argv, VALUE klass)
130
176
  static VALUE
131
177
  rb_grn_plugin_s_system_plugins_dir (VALUE klass)
132
178
  {
133
- return rb_str_new2(grn_plugin_get_system_plugins_dir());
179
+ return rb_str_new_cstr(grn_plugin_get_system_plugins_dir());
134
180
  }
135
181
 
136
182
  /*
@@ -142,7 +188,7 @@ rb_grn_plugin_s_system_plugins_dir (VALUE klass)
142
188
  static VALUE
143
189
  rb_grn_plugin_s_suffix (VALUE klass)
144
190
  {
145
- return rb_str_new2(grn_plugin_get_suffix());
191
+ return rb_str_new_cstr(grn_plugin_get_suffix());
146
192
  }
147
193
 
148
194
  void
@@ -153,6 +199,8 @@ rb_grn_init_plugin (VALUE mGrn)
153
199
 
154
200
  rb_define_singleton_method(cGrnPlugin, "register",
155
201
  rb_grn_plugin_s_register, -1);
202
+ rb_define_singleton_method(cGrnPlugin, "unregister",
203
+ rb_grn_plugin_s_unregister, -1);
156
204
  rb_define_singleton_method(cGrnPlugin, "system_plugins_dir",
157
205
  rb_grn_plugin_s_system_plugins_dir, 0);
158
206
  rb_define_singleton_method(cGrnPlugin, "suffix",
@@ -0,0 +1,86 @@
1
+ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
+ /*
3
+ Copyright (C) 2015 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_cGrnPrefixOperator;
22
+
23
+ /*
24
+ * Executes a prefix-search operation. Prefix-serach operation checks
25
+ * whether `text` starts with `prefix` or not.
26
+ *
27
+ * @example Executes prefix-search operations with the default context
28
+ * Groonga::Operator::PREFIX.exec("Hello Rroonga", "Hello") # => true
29
+ * Groonga::Operator::PREFIX.exec("Hello Rroonga", "Rroonga") # => false
30
+ *
31
+ * @example Executes prefix-search operations with the specified context
32
+ * context = Groonga::Context.new
33
+ * Groonga::Operator::PREFIX.exec("Hello Rroonga", "Hello",
34
+ * :context => context) # => true
35
+ * Groonga::Operator::PREFIX.exec("Hello Rroonga", "Rroonga",
36
+ * :context => context) # => false
37
+ *
38
+ * @overload exec(text, prefix, options={})
39
+ * @param text [String] The text to be searched.
40
+ * @param prefix [String] The prefix to be contained.
41
+ * @param options [::Hash] The options.
42
+ * @option options [Groonga::Context] (Groonga::Context.default)
43
+ * The context to executes the operation.
44
+ * @return [Boolean] `true` if `text` starts with `prefix`, `false`
45
+ * otherwise.
46
+ */
47
+ static VALUE
48
+ rb_grn_prefix_operator_exec (int argc, VALUE *argv, VALUE self)
49
+ {
50
+ grn_bool have_prefix;
51
+ VALUE rb_text;
52
+ VALUE rb_prefix;
53
+ VALUE rb_options;
54
+ VALUE rb_context;
55
+ grn_ctx *context;
56
+ grn_obj text;
57
+ grn_obj prefix;
58
+
59
+ rb_scan_args(argc, argv, "21", &rb_text, &rb_prefix, &rb_options);
60
+
61
+ rb_grn_scan_options(rb_options,
62
+ "context", &rb_context,
63
+ NULL);
64
+ context = rb_grn_context_ensure(&rb_context);
65
+
66
+ GRN_VOID_INIT(&text);
67
+ GRN_VOID_INIT(&prefix);
68
+ RVAL2GRNBULK(rb_text, context, &text);
69
+ RVAL2GRNBULK(rb_prefix, context, &prefix);
70
+ have_prefix = grn_operator_exec_prefix(context, &text, &prefix);
71
+ GRN_OBJ_FIN(context, &text);
72
+ GRN_OBJ_FIN(context, &prefix);
73
+
74
+ return CBOOL2RVAL(have_prefix);
75
+ }
76
+
77
+ void
78
+ rb_grn_init_prefix_operator (VALUE mGrn)
79
+ {
80
+ rb_cGrnPrefixOperator = rb_define_class_under(mGrn,
81
+ "PrefixOperator",
82
+ rb_cGrnOperator);
83
+
84
+ rb_define_method(rb_cGrnPrefixOperator, "exec",
85
+ rb_grn_prefix_operator_exec, -1);
86
+ }
@@ -37,4 +37,8 @@ rb_grn_init_procedure_type (VALUE mGrn)
37
37
  "HOOK", INT2NUM(GRN_PROC_HOOK));
38
38
  rb_define_const(rb_mGrnProcedureType,
39
39
  "NORMALIZER", INT2NUM(GRN_PROC_NORMALIZER));
40
+ rb_define_const(rb_mGrnProcedureType,
41
+ "TOKEN_FILTER", INT2NUM(GRN_PROC_TOKEN_FILTER));
42
+ rb_define_const(rb_mGrnProcedureType,
43
+ "SCORER", INT2NUM(GRN_PROC_SCORER));
40
44
  }
@@ -58,9 +58,9 @@ rb_grn_query_logger_log (grn_ctx *ctx, unsigned int flag,
58
58
  /* TODO: use rb_protect(). */
59
59
  rb_funcall(handler, id_log, 4,
60
60
  GRNQUERYLOGFLAGS2RVAL(flag),
61
- rb_str_new2(timestamp),
62
- rb_str_new2(info),
63
- rb_str_new2(message));
61
+ rb_str_new_cstr(timestamp),
62
+ rb_str_new_cstr(info),
63
+ rb_str_new_cstr(message));
64
64
  }
65
65
 
66
66
  static void
@@ -234,7 +234,7 @@ rb_grn_query_logger_s_get_path (VALUE klass)
234
234
 
235
235
  path = grn_default_query_logger_get_path();
236
236
  if (path) {
237
- rb_path = rb_str_new2(path);
237
+ rb_path = rb_str_new_cstr(path);
238
238
  }
239
239
  return rb_path;
240
240
  }
@@ -0,0 +1,85 @@
1
+ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
+ /*
3
+ Copyright (C) 2015 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_cGrnRegexpOperator;
22
+
23
+ /*
24
+ * Executes a regular expression match operation.
25
+ *
26
+ * @example Executes regular expression match operations with the default context
27
+ * Groonga::Operator::REGEXP.exec("Hello Rroonga", /Rro+nga/) # => true
28
+ * Groonga::Operator::REGEXP.exec("Hello Rroonga", /Gro+nga/) # => false
29
+ *
30
+ * @example Executes regular expression match operations with the specified context
31
+ * context = Groonga::Context.new
32
+ * Groonga::Operator::REGEXP.exec("Hello Rroonga", /Rro+nga/,
33
+ * :context => context) # => true
34
+ * Groonga::Operator::REGEXP.exec("Hello Rroonga", /Gro+nga/,
35
+ * :context => context) # => false
36
+ *
37
+ * @overload exec(text, regexp, options={})
38
+ * @param text [String] The text to be matched.
39
+ * @param regexp [Regexp] The regular expression.
40
+ * @param options [::Hash] The options.
41
+ * @option options [Groonga::Context] (Groonga::Context.default)
42
+ * The context to executes the operation.
43
+ * @return [Boolean] `true` if `text` matches `regexp`, `false`
44
+ * otherwise.
45
+ */
46
+ static VALUE
47
+ rb_grn_regexp_operator_exec (int argc, VALUE *argv, VALUE self)
48
+ {
49
+ grn_bool matched;
50
+ VALUE rb_text;
51
+ VALUE rb_regexp;
52
+ VALUE rb_options;
53
+ VALUE rb_context;
54
+ grn_ctx *context;
55
+ grn_obj text;
56
+ grn_obj regexp;
57
+
58
+ rb_scan_args(argc, argv, "21", &rb_text, &rb_regexp, &rb_options);
59
+
60
+ rb_grn_scan_options(rb_options,
61
+ "context", &rb_context,
62
+ NULL);
63
+ context = rb_grn_context_ensure(&rb_context);
64
+
65
+ GRN_VOID_INIT(&text);
66
+ GRN_VOID_INIT(&regexp);
67
+ RVAL2GRNBULK(rb_text, context, &text);
68
+ RVAL2GRNBULK(rb_regexp, context, &regexp);
69
+ matched = grn_operator_exec_regexp(context, &text, &regexp);
70
+ GRN_OBJ_FIN(context, &text);
71
+ GRN_OBJ_FIN(context, &regexp);
72
+
73
+ return CBOOL2RVAL(matched);
74
+ }
75
+
76
+ void
77
+ rb_grn_init_regexp_operator (VALUE mGrn)
78
+ {
79
+ rb_cGrnRegexpOperator = rb_define_class_under(mGrn,
80
+ "RegexpOperator",
81
+ rb_cGrnOperator);
82
+
83
+ rb_define_method(rb_cGrnRegexpOperator, "exec",
84
+ rb_grn_regexp_operator_exec, -1);
85
+ }
@@ -146,7 +146,7 @@ rb_grn_snippet_initialize (int argc, VALUE *argv, VALUE self)
146
146
  default_open_tag, default_open_tag_length,
147
147
  default_close_tag, default_close_tag_length,
148
148
  mapping);
149
- rb_grn_context_check(context, rb_ary_new4(argc, argv));
149
+ rb_grn_context_check(context, rb_ary_new_from_values(argc, argv));
150
150
 
151
151
  rb_grn_object_assign(Qnil, self, rb_context, context, snippet);
152
152
  rb_grn_context_register_floating_object(DATA_PTR(self));
@@ -196,7 +196,7 @@ rb_grn_table_key_support_inspect (VALUE self)
196
196
  {
197
197
  VALUE inspected;
198
198
 
199
- inspected = rb_str_new2("");
199
+ inspected = rb_str_new_cstr("");
200
200
  rb_grn_object_inspect_header(self, inspected);
201
201
  rb_grn_object_inspect_content(self, inspected);
202
202
  rb_grn_table_inspect_content(self, inspected);
@@ -525,7 +525,9 @@ rb_grn_table_key_support_array_set (VALUE self, VALUE rb_key, VALUE rb_values)
525
525
  if (id == GRN_ID_NIL) {
526
526
  rb_raise(rb_eGrnError,
527
527
  "failed to add record: %s",
528
- rb_grn_inspect(rb_ary_new3(3, self, rb_key, rb_values)));
528
+ rb_grn_inspect(rb_ary_new_from_args(3,
529
+ self,
530
+ rb_key, rb_values)));
529
531
  }
530
532
 
531
533
  data.self = self;
@@ -568,9 +570,11 @@ rb_grn_table_key_support_set_column_value (int argc, VALUE *argv, VALUE self)
568
570
  if (id == GRN_ID_NIL) {
569
571
  rb_raise(rb_eGrnError,
570
572
  "failed to add record: %s",
571
- rb_grn_inspect(rb_ary_new3(4,
572
- self, rb_key,
573
- rb_name, rb_value)));
573
+ rb_grn_inspect(rb_ary_new_from_args(4,
574
+ self,
575
+ rb_key,
576
+ rb_name,
577
+ rb_value)));
574
578
  }
575
579
 
576
580
  return rb_grn_table_set_column_value_raw(self, id, rb_name, rb_value);
@@ -1,7 +1,7 @@
1
1
  /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
2
  /*
3
3
  Copyright (C) 2014-2015 Masafumi Yokoyama <yokoyama@clear-code.com>
4
- Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
4
+ Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
5
5
 
6
6
  This library is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU Lesser General Public
@@ -199,7 +199,7 @@ rb_grn_table_inspect (VALUE self)
199
199
  {
200
200
  VALUE inspected;
201
201
 
202
- inspected = rb_str_new2("");
202
+ inspected = rb_str_new_cstr("");
203
203
  rb_grn_object_inspect_header(self, inspected);
204
204
  rb_grn_object_inspect_content(self, inspected);
205
205
  rb_grn_table_inspect_content(self, inspected);
@@ -238,7 +238,7 @@ rb_grn_table_inspect (VALUE self)
238
238
  * - +:zlib+ := 値をzlib圧縮して格納する。
239
239
  * - +:lz4+ := 値をLZ4圧縮して格納する。
240
240
  *
241
- * @return [Groonga::FixSizeColumn or Groonga::VariableSizeColumn]
241
+ * @return [Groonga::FixSizeColumn, Groonga::VariableSizeColumn]
242
242
  */
243
243
  static VALUE
244
244
  rb_grn_table_define_column (int argc, VALUE *argv, VALUE self)
@@ -328,8 +328,12 @@ rb_grn_table_define_column (int argc, VALUE *argv, VALUE self)
328
328
  column = grn_column_create(context, table, name, name_size,
329
329
  path, flags, value_type);
330
330
  if (context->rc) {
331
- rb_grn_context_check(context,
332
- rb_ary_new3(2, self, rb_ary_new4(argc, argv)));
331
+ VALUE rb_related_object;
332
+ rb_related_object =
333
+ rb_ary_new_from_args(2,
334
+ self,
335
+ rb_ary_new_from_values(argc, argv));
336
+ rb_grn_context_check(context, rb_related_object);
333
337
  }
334
338
 
335
339
  rb_column = GRNCOLUMN2RVAL(Qnil, context, column, GRN_TRUE);
@@ -451,8 +455,10 @@ rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
451
455
  column = grn_column_create(context, table, name, name_size,
452
456
  path, flags, value_type);
453
457
  if (context->rc) {
454
- rb_grn_context_check(context,
455
- rb_ary_new3(2, self, rb_ary_new4(argc, argv)));
458
+ VALUE rb_related_object;
459
+ rb_related_object =
460
+ rb_ary_new_from_args(2, self, rb_ary_new_from_values(argc, argv));
461
+ rb_grn_context_check(context, rb_related_object);
456
462
  }
457
463
 
458
464
  rb_column = GRNCOLUMN2RVAL(Qnil, context, column, GRN_TRUE);
@@ -494,7 +500,7 @@ ruby_object_to_column_name (VALUE rb_name,
494
500
  * い場合は +nil+ を返す。
495
501
  *
496
502
  * @overload column(name)
497
- * @return [Groonga::Column or nil]
503
+ * @return [Groonga::Column, nil]
498
504
  */
499
505
  VALUE
500
506
  rb_grn_table_get_column (VALUE self, VALUE rb_name)
@@ -1338,7 +1344,7 @@ rb_grn_table_sort (int argc, VALUE *argv, VALUE self)
1338
1344
  * @option options :max_n_sub_records
1339
1345
  * グループ化した後のレコードのそれぞれについて最大 _:max_n_sub_records_ 件まで
1340
1346
  * そのグループに含まれる _table_ のレコードをサブレコードとして格納する。
1341
- * @option options [String or Symbol] :calc_target
1347
+ * @option options [String, Symbol] :calc_target
1342
1348
  * The target column name for _:calc_types_.
1343
1349
  * @option options [::Array] :calc_types
1344
1350
  * It specifies how to calculate (aggregate) values in grouped records by
@@ -1584,10 +1590,14 @@ rb_grn_table_get_value_convenience (int argc, VALUE *argv, VALUE self)
1584
1590
  "id", &rb_option_id,
1585
1591
  NULL);
1586
1592
  if (!(NIL_P(rb_option_id) || RVAL2CBOOL(rb_option_id))) {
1593
+ VALUE rb_related_object;
1594
+ rb_related_object =
1595
+ rb_ary_new_from_args(2,
1596
+ self,
1597
+ rb_ary_new_from_values(argc, argv));
1587
1598
  rb_raise(rb_eArgError, ":id options must be true or nil: %s: %s",
1588
1599
  rb_grn_inspect(rb_option_id),
1589
- rb_grn_inspect(rb_ary_new3(2,
1590
- self, rb_ary_new4(argc, argv))));
1600
+ rb_grn_inspect(rb_related_object));
1591
1601
  }
1592
1602
  }
1593
1603
 
@@ -1642,10 +1652,14 @@ rb_grn_table_set_value_convenience (int argc, VALUE *argv, VALUE self)
1642
1652
  "id", &rb_option_id,
1643
1653
  NULL);
1644
1654
  if (!(NIL_P(rb_option_id) || RVAL2CBOOL(rb_option_id))) {
1655
+ VALUE rb_related_object;
1656
+ rb_related_object =
1657
+ rb_ary_new_from_args(2,
1658
+ self,
1659
+ rb_ary_new_from_values(argc, argv));
1645
1660
  rb_raise(rb_eArgError, ":id options must be true or nil: %s: %s",
1646
1661
  rb_grn_inspect(rb_option_id),
1647
- rb_grn_inspect(rb_ary_new3(2,
1648
- self, rb_ary_new4(argc, argv))));
1662
+ rb_grn_inspect(rb_related_object));
1649
1663
  }
1650
1664
  }
1651
1665
 
@@ -1693,11 +1707,14 @@ rb_grn_table_get_column_value_convenience (int argc, VALUE *argv, VALUE self)
1693
1707
  "id", &rb_option_id,
1694
1708
  NULL);
1695
1709
  if (!(NIL_P(rb_option_id) || RVAL2CBOOL(rb_option_id))) {
1710
+ VALUE rb_related_object;
1711
+ rb_related_object =
1712
+ rb_ary_new_from_args(2,
1713
+ self,
1714
+ rb_ary_new_from_values(argc, argv));
1696
1715
  rb_raise(rb_eArgError, ":id options must be true or nil: %s: %s",
1697
1716
  rb_grn_inspect(rb_option_id),
1698
- rb_grn_inspect(rb_ary_new3(2,
1699
- self,
1700
- rb_ary_new4(argc, argv))));
1717
+ rb_grn_inspect(rb_related_object));
1701
1718
  }
1702
1719
  }
1703
1720
 
@@ -1733,7 +1750,7 @@ rb_grn_table_set_column_value (VALUE self, VALUE rb_id,
1733
1750
  * @overload set_column_value(id, name, value)
1734
1751
  * @!macro [new] table.set_column_value.base_arguments
1735
1752
  * @param id [Integer] The ID of the target record.
1736
- * @param name [String or Symbol] The name of the target column.
1753
+ * @param name [String, Symbol] The name of the target column.
1737
1754
  * @!macro [new] table.set_column_value.value
1738
1755
  * @param value [::Object] The new value.
1739
1756
  *
@@ -1894,11 +1911,14 @@ rb_grn_table_set_column_value_convenience (int argc, VALUE *argv, VALUE self)
1894
1911
  "id", &rb_option_id,
1895
1912
  NULL);
1896
1913
  if (!(NIL_P(rb_option_id) || RVAL2CBOOL(rb_option_id))) {
1914
+ VALUE rb_related_object;
1915
+ rb_related_object =
1916
+ rb_ary_new_from_args(2,
1917
+ self,
1918
+ rb_ary_new_from_values(argc, argv));
1897
1919
  rb_raise(rb_eArgError, ":id options must be true or nil: %s: %s",
1898
1920
  rb_grn_inspect(rb_option_id),
1899
- rb_grn_inspect(rb_ary_new3(2,
1900
- self,
1901
- rb_ary_new4(argc, argv))));
1921
+ rb_grn_inspect(rb_related_object));
1902
1922
  }
1903
1923
  }
1904
1924
 
@@ -2019,78 +2039,44 @@ rb_grn_table_lock (int argc, VALUE *argv, VALUE self)
2019
2039
  }
2020
2040
 
2021
2041
  /*
2022
- * _table_ のロックを強制的に解除する。
2042
+ * Forces to clear lock of the `table`.
2023
2043
  *
2024
- * @overload clear_lock(options={})
2025
- * @param [::Hash] options The name and value
2026
- * pairs. Omitted names are initialized as the default value.
2027
- * @option options :id
2028
- * _:id_ で指定したレコードのロックを強制的に解除する。
2029
- * (注: groonga側が未実装のため、現在は無視される。実装さ
2030
- * れるのではないかと思っているが、実装されないかもしれな
2031
- * い。)
2044
+ * @overload clear_lock
2045
+ * @return [void]
2032
2046
  */
2033
2047
  static VALUE
2034
- rb_grn_table_clear_lock (int argc, VALUE *argv, VALUE self)
2048
+ rb_grn_table_clear_lock (VALUE self)
2035
2049
  {
2036
- grn_id id = GRN_ID_NIL;
2037
2050
  grn_ctx *context;
2038
2051
  grn_obj *table;
2039
- VALUE options, rb_id;
2040
-
2041
- rb_scan_args(argc, argv, "01", &options);
2042
2052
 
2043
2053
  rb_grn_table_deconstruct(SELF(self), &table, &context,
2044
2054
  NULL, NULL,
2045
2055
  NULL, NULL, NULL,
2046
2056
  NULL);
2047
2057
 
2048
- rb_grn_scan_options(options,
2049
- "id", &rb_id,
2050
- NULL);
2051
-
2052
- if (!NIL_P(rb_id))
2053
- id = NUM2UINT(rb_id);
2054
-
2055
2058
  grn_obj_clear_lock(context, table);
2056
2059
 
2057
2060
  return Qnil;
2058
2061
  }
2059
2062
 
2060
2063
  /*
2061
- * _table_ がロックされていれば +true+ を返す。
2064
+ * Checks whether the `table` is locked or not.
2062
2065
  *
2063
- * @overload locked?(options={})
2064
- * @param [options] options The name and value
2065
- * pairs. Omitted names are initialized as the default value.
2066
- * @option options :id
2067
- * _:id_ で指定したレコードがロックされていれば +true+ を返す。
2068
- * (注: groonga側が未実装のため、現在は無視される。実装さ
2069
- * れるのではないかと思っているが、実装されないかもしれな
2070
- * い。)
2066
+ * @overload locked?
2067
+ * @return [Boolean] `true` if the `table` is locked, `false` otherwise.
2071
2068
  */
2072
2069
  static VALUE
2073
- rb_grn_table_is_locked (int argc, VALUE *argv, VALUE self)
2070
+ rb_grn_table_locked_p (VALUE self)
2074
2071
  {
2075
- grn_id id = GRN_ID_NIL;
2076
2072
  grn_ctx *context;
2077
2073
  grn_obj *table;
2078
- VALUE options, rb_id;
2079
-
2080
- rb_scan_args(argc, argv, "01", &options);
2081
2074
 
2082
2075
  rb_grn_table_deconstruct(SELF(self), &table, &context,
2083
2076
  NULL, NULL,
2084
2077
  NULL, NULL, NULL,
2085
2078
  NULL);
2086
2079
 
2087
- rb_grn_scan_options(options,
2088
- "id", &rb_id,
2089
- NULL);
2090
-
2091
- if (!NIL_P(rb_id))
2092
- id = NUM2UINT(rb_id);
2093
-
2094
2080
  return CBOOL2RVAL(grn_obj_is_locked(context, table));
2095
2081
  }
2096
2082
 
@@ -2257,7 +2243,7 @@ rb_grn_table_select (int argc, VALUE *argv, VALUE self)
2257
2243
  "should be [query_string, option_hash], "
2258
2244
  "[expression, option_hash] "
2259
2245
  "or [option_hash]: %s",
2260
- rb_grn_inspect(rb_ary_new4(argc, argv)));
2246
+ rb_grn_inspect(rb_ary_new_from_values(argc, argv)));
2261
2247
  options = condition_or_options;
2262
2248
  }
2263
2249
 
@@ -2285,7 +2271,7 @@ rb_grn_table_select (int argc, VALUE *argv, VALUE self)
2285
2271
  if (!result) {
2286
2272
  rb_raise(rb_eGrnNoMemoryAvailable,
2287
2273
  "failed to create result table: %s",
2288
- rb_grn_inspect(rb_ary_new4(argc, argv)));
2274
+ rb_grn_inspect(rb_ary_new_from_values(argc, argv)));
2289
2275
  }
2290
2276
  rb_result = GRNTABLE2RVAL(context, result, GRN_TRUE);
2291
2277
  } else {
@@ -2631,8 +2617,8 @@ rb_grn_init_table (VALUE mGrn)
2631
2617
 
2632
2618
  rb_define_method(rb_cGrnTable, "lock", rb_grn_table_lock, -1);
2633
2619
  rb_define_method(rb_cGrnTable, "unlock", rb_grn_table_unlock, -1);
2634
- rb_define_method(rb_cGrnTable, "clear_lock", rb_grn_table_clear_lock, -1);
2635
- rb_define_method(rb_cGrnTable, "locked?", rb_grn_table_is_locked, -1);
2620
+ rb_define_method(rb_cGrnTable, "clear_lock", rb_grn_table_clear_lock, 0);
2621
+ rb_define_method(rb_cGrnTable, "locked?", rb_grn_table_locked_p, 0);
2636
2622
 
2637
2623
  rb_define_method(rb_cGrnTable, "select", rb_grn_table_select, -1);
2638
2624