rroonga 1.2.9 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/Gemfile +1 -0
  2. data/Rakefile +1 -0
  3. data/bin/grntest-log-analyze +123 -0
  4. data/bin/groonga-query-log-extract +117 -0
  5. data/ext/groonga/rb-grn-accessor.c +7 -5
  6. data/ext/groonga/rb-grn-array-cursor.c +1 -1
  7. data/ext/groonga/rb-grn-array.c +34 -44
  8. data/ext/groonga/rb-grn-column.c +74 -38
  9. data/ext/groonga/rb-grn-context.c +19 -15
  10. data/ext/groonga/rb-grn-database.c +47 -42
  11. data/ext/groonga/rb-grn-double-array-trie-cursor.c +40 -0
  12. data/ext/groonga/rb-grn-double-array-trie.c +530 -0
  13. data/ext/groonga/rb-grn-encoding-support.c +1 -1
  14. data/ext/groonga/rb-grn-encoding.c +1 -1
  15. data/ext/groonga/rb-grn-exception.c +1 -1
  16. data/ext/groonga/rb-grn-expression-builder.c +1 -1
  17. data/ext/groonga/rb-grn-expression.c +63 -51
  18. data/ext/groonga/rb-grn-fix-size-column.c +7 -7
  19. data/ext/groonga/rb-grn-hash-cursor.c +1 -1
  20. data/ext/groonga/rb-grn-hash.c +42 -39
  21. data/ext/groonga/rb-grn-index-column.c +35 -31
  22. data/ext/groonga/rb-grn-index-cursor.c +1 -1
  23. data/ext/groonga/rb-grn-logger.c +23 -18
  24. data/ext/groonga/rb-grn-object.c +40 -27
  25. data/ext/groonga/rb-grn-operator.c +1 -1
  26. data/ext/groonga/rb-grn-patricia-trie-cursor.c +1 -1
  27. data/ext/groonga/rb-grn-patricia-trie.c +122 -90
  28. data/ext/groonga/rb-grn-plugin.c +8 -7
  29. data/ext/groonga/rb-grn-posting.c +1 -1
  30. data/ext/groonga/rb-grn-procedure.c +1 -1
  31. data/ext/groonga/rb-grn-query.c +12 -12
  32. data/ext/groonga/rb-grn-record.c +1 -1
  33. data/ext/groonga/rb-grn-snippet.c +26 -19
  34. data/ext/groonga/rb-grn-table-cursor-key-support.c +1 -1
  35. data/ext/groonga/rb-grn-table-cursor.c +4 -3
  36. data/ext/groonga/rb-grn-table-key-support.c +23 -23
  37. data/ext/groonga/rb-grn-table.c +268 -153
  38. data/ext/groonga/rb-grn-type.c +11 -7
  39. data/ext/groonga/rb-grn-utils.c +4 -1
  40. data/ext/groonga/rb-grn-variable-size-column.c +1 -1
  41. data/ext/groonga/rb-grn-variable.c +2 -2
  42. data/ext/groonga/rb-grn-view-accessor.c +1 -1
  43. data/ext/groonga/rb-grn-view-cursor.c +1 -1
  44. data/ext/groonga/rb-grn-view-record.c +1 -1
  45. data/ext/groonga/rb-grn-view.c +43 -34
  46. data/ext/groonga/rb-grn.h +6 -2
  47. data/ext/groonga/rb-groonga.c +1 -1
  48. data/lib/groonga.rb +4 -2
  49. data/lib/groonga/context.rb +16 -41
  50. data/lib/groonga/dumper.rb +6 -4
  51. data/lib/groonga/expression-builder.rb +52 -26
  52. data/lib/groonga/grntest-log.rb +206 -0
  53. data/lib/groonga/pagination.rb +21 -19
  54. data/lib/groonga/patricia-trie.rb +7 -10
  55. data/lib/groonga/posting.rb +1 -1
  56. data/lib/groonga/query-log.rb +348 -0
  57. data/lib/groonga/record.rb +47 -143
  58. data/lib/groonga/schema.rb +679 -406
  59. data/lib/groonga/view-record.rb +4 -10
  60. data/rroonga-build.rb +1 -1
  61. data/test/test-array.rb +25 -4
  62. data/test/test-column.rb +8 -8
  63. data/test/test-database.rb +2 -3
  64. data/test/test-double-array-trie.rb +164 -0
  65. data/test/test-expression-builder.rb +2 -2
  66. data/test/test-expression.rb +10 -9
  67. data/test/test-gqtp.rb +2 -2
  68. data/test/test-hash.rb +32 -8
  69. data/test/test-patricia-trie.rb +34 -10
  70. data/test/test-query-log.rb +258 -0
  71. data/test/test-record.rb +6 -5
  72. data/test/test-schema-create-table.rb +8 -0
  73. data/test/test-schema.rb +491 -234
  74. data/test/test-table.rb +17 -24
  75. metadata +123 -100
  76. data/ext/groonga/Makefile +0 -233
@@ -1,4 +1,4 @@
1
- /* -*- c-file-style: "ruby" -*- */
1
+ /* -*- coding: utf-8; c-file-style: "ruby" -*- */
2
2
  /*
3
3
  Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
4
4
 
@@ -132,17 +132,17 @@ rb_grn_operator_from_ruby_object (VALUE rb_operator)
132
132
  * call-seq:
133
133
  * query.new(string, options={})
134
134
  *
135
- * _string_をパースした上で、クエリを作成する。作成されたオ
135
+ * _string_ をパースした上で、クエリを作成する。作成されたオ
136
136
  * ブジェクトはGroonga::IndexColumn#searchに渡すことで使用す
137
137
  * ることができる。
138
138
  *
139
- * _options_に指定可能な値は以下の通り。
139
+ * _options_ に指定可能な値は以下の通り。
140
+ * @param options [::Hash] The name and value
141
+ * pairs. Omitted names are initialized as the default value.
142
+ * @option options :context (Groonga::Context.default) The context
143
+ * クエリが利用するGroonga::Context。
140
144
  *
141
- * [+:context+]
142
- * クエリが利用するGroonga::Context。省略すると
143
- * Groonga::Context.defaultを用いる。
144
- *
145
- * [+:default_operator+]
145
+ * @option options :default_operator The default_operator
146
146
  * 演算子の既定値(演算子を省略した場合にどの演算を行うか)
147
147
  * を指定する。
148
148
  *
@@ -153,7 +153,7 @@ rb_grn_operator_from_ruby_object (VALUE rb_operator)
153
153
  * (FIXME: 挙動の違いを検証する必要性あり?
154
154
  * Groonga::Expressionとの関連性は?)
155
155
  *
156
- * [+:max_expressions+]
156
+ * @option options :max_expressions
157
157
  * 検索クエリに指定する式の最大値を指定する。
158
158
  */
159
159
  static VALUE
@@ -206,7 +206,7 @@ rb_grn_query_initialize (int argc, VALUE *argv, VALUE self)
206
206
  * call-seq:
207
207
  * query.close
208
208
  *
209
- * _query_が使用しているリソースを開放する。これ以降_query_を
209
+ * _query_ が使用しているリソースを開放する。これ以降 _query_
210
210
  * 使うことはできない。
211
211
  */
212
212
  static VALUE
@@ -230,8 +230,8 @@ rb_grn_query_close (VALUE self)
230
230
  * call-seq:
231
231
  * query.closed? -> true/false
232
232
  *
233
- * _query_が開放済みの場合は+true+を返し、そうでない場合は
234
- * +false+を返す。
233
+ * _query_ が開放済みの場合は +true+ を返し、そうでない場合は
234
+ * +false+ を返す。
235
235
  */
236
236
  static VALUE
237
237
  rb_grn_query_closed_p (VALUE self)
@@ -1,4 +1,4 @@
1
- /* -*- c-file-style: "ruby" -*- */
1
+ /* -*- coding: utf-8; c-file-style: "ruby" -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
4
4
 
@@ -1,4 +1,4 @@
1
- /* -*- c-file-style: "ruby" -*- */
1
+ /* -*- coding: utf-8; c-file-style: "ruby" -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
4
4
 
@@ -103,35 +103,39 @@ rb_grn_snippet_alloc (VALUE klass)
103
103
  * call-seq:
104
104
  * Groonga::Snippet.new(options={})
105
105
  *
106
- * スニペットを作成する。_options_に指定可能な値は以下の通
106
+ * スニペットを作成する。 _options_ に指定可能な値は以下の通
107
107
  * り。
108
+ * @param options [::Hash] The name and value
109
+ * pairs. Omitted names are initialized as the default value.
110
+ * @option options :context (Groonga::Context.default) The context
108
111
  *
109
- * [+:context+]
110
112
  * スキーマ作成時に使用するGroonga::Contextを指定する。
111
- * 省略した場合はGroonga::Context.defaultを使用する。
112
113
  *
113
- * [+:normalize+]
114
+ * @option options :normalize The normalize
115
+ *
114
116
  * キーワード文字列・スニペット元の文字列を正規化するかど
115
- * うか。省略した場合は+false+で正規化しない。
117
+ * うか。省略した場合は +false+ で正規化しない。
118
+ *
119
+ * @option options :skip_leading_spaces (false) The skip_leading_spaces
116
120
  *
117
- * [+:skip_leading_spaces+]
118
- * 先頭の空白を無視するかどうか。省略した場合は+false+で無
121
+ * 先頭の空白を無視するかどうか。省略した場合は で無
119
122
  * 視しない。
120
123
  *
121
- * [+:width+]
124
+ * @option options :width (100) The width
125
+ *
122
126
  * スニペット文字列の長さ。省略した場合は100文字。
123
127
  *
124
- * [+:max_results+]
128
+ * @option options :max_results (3) The max_results
125
129
  * 生成するスニペットの最大数。省略した場合は3。
126
130
  *
127
- * [+:html_escape+]
131
+ * @option options :html_escape (false) The html_escape
128
132
  * スニペット内の+<+, +>+, +&+, +"+をHTMLエスケープするか
129
133
  * どうか。省略した場合は+false+で、HTMLエスケープしない。
130
134
  *
131
- * [+:default_open_tag+]
135
+ * @option options :default_open_tag ("") The default_open_tag
132
136
  * デフォルトの開始タグ。省略した場合は""(空文字列)
133
137
  *
134
- * [+:default_close_tag+]
138
+ * @option options :default_close_tag ("") The default_close_tag
135
139
  * デフォルトの終了タグ。省略した場合は""(空文字列)
136
140
  */
137
141
  static VALUE
@@ -213,14 +217,17 @@ rb_grn_snippet_initialize (int argc, VALUE *argv, VALUE self)
213
217
  * call-seq:
214
218
  * snippet.add_keyword(keyword, options={})
215
219
  *
216
- * _keyword_を追加する。_options_に指定可能な値は以下の通
217
- * り。
220
+ * _keyword_ を追加する。 _options_ に指定可能な値は
221
+ * 以下の通り。
222
+ * @param options [::Hash] The name and value
223
+ * pairs. Omitted names are initialized as the default value.
224
+ * @option options :open_tag (default_open_tag) The open_tag
218
225
  *
219
- * [+:open_tag+]
220
226
  * 開始タグ。省略した場合はGroonga::Snippet.newで指定し
221
227
  * た+:default_open_tag+。
222
228
  *
223
- * [+:close_tag+]
229
+ * @option options :close_tag (:default_close_tag) The close_tag
230
+ *
224
231
  * 終了タグ。省略した場合はGroonga::Snippet.newで指定し
225
232
  * た+:default_close_tag+。
226
233
  */
@@ -276,7 +283,7 @@ rb_grn_snippet_add_keyword (int argc, VALUE *argv, VALUE self)
276
283
  * call-seq:
277
284
  * snippet.execute(string) -> スニペットの配列
278
285
  *
279
- * _string_を走査し、スニペットを作成する。
286
+ * _string_ を走査し、スニペットを作成する。
280
287
  */
281
288
  static VALUE
282
289
  rb_grn_snippet_execute (VALUE self, VALUE rb_string)
@@ -339,7 +346,7 @@ rb_grn_snippet_execute (VALUE self, VALUE rb_string)
339
346
  * call-seq:
340
347
  * snippet.close
341
348
  *
342
- * _snippet_が使用しているリソースを開放する。これ以降_snippet_を
349
+ * _snippet_ が使用しているリソースを開放する。これ以降 _snippet_
343
350
  * 使うことはできない。
344
351
  */
345
352
  static VALUE
@@ -1,4 +1,4 @@
1
- /* -*- c-file-style: "ruby" -*- */
1
+ /* -*- coding: utf-8; c-file-style: "ruby" -*- */
2
2
  /*
3
3
  Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
4
4
 
@@ -1,4 +1,4 @@
1
- /* -*- c-file-style: "ruby" -*- */
1
+ /* -*- coding: utf-8; c-file-style: "ruby" -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
4
4
 
@@ -270,8 +270,8 @@ rb_grn_table_cursor_each (VALUE self)
270
270
  * call-seq:
271
271
  * cursor.closed? -> true/false
272
272
  *
273
- * カーソルが開放済みの場合は+true+を返し、そうでない場合は
274
- * +false+を返す。
273
+ * カーソルが開放済みの場合は +true+ を返し、そうでない場合は
274
+ * +false+ を返す。
275
275
  */
276
276
 
277
277
  void
@@ -303,5 +303,6 @@ rb_grn_init_table_cursor (VALUE mGrn)
303
303
  rb_grn_init_array_cursor(mGrn);
304
304
  rb_grn_init_hash_cursor(mGrn);
305
305
  rb_grn_init_patricia_trie_cursor(mGrn);
306
+ rb_grn_init_double_array_trie_cursor(mGrn);
306
307
  rb_grn_init_view_cursor(mGrn);
307
308
  }
@@ -1,4 +1,4 @@
1
- /* -*- c-file-style: "ruby" -*- */
1
+ /* -*- coding: utf-8; c-file-style: "ruby" -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
4
4
 
@@ -113,16 +113,16 @@ rb_grn_table_key_support_add_raw (VALUE self, VALUE rb_key, int *added)
113
113
  * call-seq:
114
114
  * table.add(key, values=nil) -> Groonga::Recordまたはnil
115
115
  *
116
- * 主キーが_key_のレコード追加し、追加したレコードを返す。レ
117
- * コードの追加に失敗した場合は+nil+を返す。
116
+ * 主キーが _key_ のレコード追加し、追加したレコードを返す。レ
117
+ * コードの追加に失敗した場合は +nil+ を返す。
118
118
  *
119
119
  * すでに同じキーのレコードが存在する場合は追加せずに同じレ
120
120
  * コードを返す。追加されたかどうかは
121
- * +Groonga::Record#added?+で調べることができる。+true+を返
121
+ * +Groonga::Record#added?+ で調べることができる。 +true+ を返
122
122
  * したら追加されたということを示す。
123
123
  *
124
- * _values_にはレコードのカラムに設定する値を指定する。省略
125
- * した場合または+nil+を指定した場合はカラムは設定しない。カ
124
+ * _values_ にはレコードのカラムに設定する値を指定する。省略
125
+ * した場合または +nil+ を指定した場合はカラムは設定しない。カ
126
126
  * ラムの値は<tt>{:カラム名1 => 値1, :カラム名2 => 値2,
127
127
  * ...}</tt>と指定する。
128
128
  */
@@ -172,9 +172,9 @@ rb_grn_table_key_support_get (VALUE self, VALUE rb_key)
172
172
  * table.id -> テーブルID
173
173
  * table.id(key) -> レコードID
174
174
  *
175
- * _key_を指定しない場合はテーブルのIDを返す。
175
+ * _key_ を指定しない場合はテーブルのIDを返す。
176
176
  *
177
- * _key_を指定した場合はテーブルの_key_に対応するレコードの
177
+ * _key_ を指定した場合はテーブルの _key_ に対応するレコードの
178
178
  * IDを返す。
179
179
  */
180
180
  static VALUE
@@ -201,7 +201,7 @@ rb_grn_table_key_support_get_id (int argc, VALUE *argv, VALUE self)
201
201
  * call-seq:
202
202
  * table.key(id) -> 主キー
203
203
  *
204
- * テーブルの_id_に対応する主キーを返す。
204
+ * テーブルの _id_ に対応する主キーを返す。
205
205
  */
206
206
  static VALUE
207
207
  rb_grn_table_key_support_get_key (VALUE self, VALUE rb_id)
@@ -237,7 +237,7 @@ rb_grn_table_key_support_get_key (VALUE self, VALUE rb_id)
237
237
  * call-seq:
238
238
  * table.has_key?(key) -> true/false
239
239
  *
240
- * テーブルに主キーが_key_のレコードがあるならtrueを返す。
240
+ * テーブルに主キーが _key_ のレコードがあるならtrueを返す。
241
241
  */
242
242
  static VALUE
243
243
  rb_grn_table_key_support_has_key (VALUE self, VALUE rb_key)
@@ -287,7 +287,7 @@ rb_grn_table_key_support_delete_by_key (VALUE self, VALUE rb_key)
287
287
  * table.delete(id)
288
288
  * table.delete(key)
289
289
  *
290
- * テーブルの_id_または_key_に対応するレコードを削除する。
290
+ * テーブルの _id_ または _key_ に対応するレコードを削除する。
291
291
  */
292
292
  static VALUE
293
293
  rb_grn_table_key_support_delete (VALUE self, VALUE rb_id_or_key)
@@ -305,7 +305,7 @@ rb_grn_table_key_support_delete (VALUE self, VALUE rb_id_or_key)
305
305
  * call-seq:
306
306
  * table[key] -> Groonga::Record
307
307
  *
308
- * _table_の_key_に対応するGroonga::Recordを返す。
308
+ * _table_ _key_ に対応するGroonga::Recordを返す。
309
309
  *
310
310
  * 0.9.0から値ではなくGroonga::Recordを返すようになった。
311
311
  */
@@ -357,8 +357,8 @@ set_value (VALUE args, SetValueData *data)
357
357
  * call-seq:
358
358
  * table[key] = {:column_name => value, ...}
359
359
  *
360
- * _table_の_key_に対応するカラム_column_name_の値を設定する。
361
- * _key_に対応するレコードがない場合は新しく作成される。
360
+ * _table_ _key_ に対応するカラム _column_name_ の値を設定する。
361
+ * _key_ に対応するレコードがない場合は新しく作成される。
362
362
  *
363
363
  * 0.9.0から値ではなくカラムの値を設定するようになった。
364
364
  */
@@ -397,8 +397,8 @@ rb_grn_table_key_support_array_set (VALUE self, VALUE rb_key, VALUE rb_values)
397
397
  * table.set_column_value(key, name, value)
398
398
  * table.set_column_value(id, name, value, :id => true)
399
399
  *
400
- * _table_の_key_に対応するカラム_name_の値を設定する。
401
- * _key_に対応するレコードがない場合は新しく作成される。
400
+ * _table_ _key_ に対応するカラム _name_ の値を設定する。
401
+ * _key_ に対応するレコードがない場合は新しく作成される。
402
402
  */
403
403
  static VALUE
404
404
  rb_grn_table_key_support_set_column_value (int argc, VALUE *argv, VALUE self)
@@ -437,9 +437,9 @@ rb_grn_table_key_support_set_column_value (int argc, VALUE *argv, VALUE self)
437
437
  * table.column_value(key, name)
438
438
  * table.column_value(id, name, :id => true)
439
439
  *
440
- * _table_の_key_に対応するカラム_name_の値を設定する。
440
+ * _table_ _key_ に対応するカラム _name_ の値を設定する。
441
441
  *
442
- * TODO: _key_に対応するレコードがない場合は例外?
442
+ * TODO: _key_ に対応するレコードがない場合は例外?
443
443
  */
444
444
  static VALUE
445
445
  rb_grn_table_key_support_get_column_value (int argc, VALUE *argv, VALUE self)
@@ -496,7 +496,7 @@ rb_grn_table_key_support_get_value_by_key (VALUE self, VALUE rb_key)
496
496
  * table.value(id, :id => true) -> 値
497
497
  * table.value(key) -> 値
498
498
  *
499
- * _table_の_id_または_key_に対応する値を返す。
499
+ * _table_ _id_ または _key_ に対応する値を返す。
500
500
  */
501
501
  static VALUE
502
502
  rb_grn_table_key_support_get_value (int argc, VALUE *argv, VALUE self)
@@ -566,7 +566,7 @@ rb_grn_table_key_support_set_value_by_key (VALUE self,
566
566
  * table.set_value(id, value, :id => true)
567
567
  * table.set_value(key, value)
568
568
  *
569
- * _table_の_id_または_key_に対応する値を_value_に設定する。
569
+ * _table_ _id_ または _key_ に対応する値を _value_ に設定する。
570
570
  * 既存の値は上書きされる。
571
571
  */
572
572
  static VALUE
@@ -628,7 +628,7 @@ rb_grn_table_key_support_get_default_tokenizer (VALUE self)
628
628
  *
629
629
  * Groonga::IndexColumnで使用するトークナイザを設定する。
630
630
  *
631
- * 例:
631
+ * @example
632
632
  * # 2-gramを使用。
633
633
  * table.default_tokenizer = "TokenBigram"
634
634
  * # オブジェクトで指定
@@ -670,7 +670,7 @@ rb_grn_table_key_support_set_default_tokenizer (VALUE self, VALUE rb_tokenizer)
670
670
  * call-seq:
671
671
  * table.normalize_key? -> true/false
672
672
  *
673
- * キーを正規化する場合は+true+、正規化しない場合は+false+を返
673
+ * キーを正規化する場合は +true+ 、正規化しない場合は +false+ を返
674
674
  * す。
675
675
  */
676
676
  static VALUE
@@ -689,7 +689,7 @@ rb_grn_table_key_normalize_key_p (VALUE self)
689
689
  * call-seq:
690
690
  * table.support_key? -> true/false
691
691
  *
692
- * テーブルでキーを使えるなら+true+、使えないなら+false+を返
692
+ * テーブルでキーを使えるなら +true+ 、使えないなら +false+ を返
693
693
  * す。キーを使えないテーブルはGroonga::Arrayだけ。
694
694
  */
695
695
  static VALUE
@@ -1,4 +1,4 @@
1
- /* -*- c-file-style: "ruby" -*- */
1
+ /* -*- coding: utf-8; c-file-style: "ruby" -*- */
2
2
  /*
3
3
  Copyright (C) 2009-2011 Kouhei Sutou <kou@clear-code.com>
4
4
 
@@ -228,27 +228,28 @@ rb_grn_table_inspect (VALUE self)
228
228
  * table.define_column(name, value_type, options={}) ->
229
229
  * Groonga::FixSizeColumnかGroonga::VariableSizeColumn
230
230
  *
231
- * テーブルに名前が_name_で型が_value_type_のカラムを定義
231
+ * テーブルに名前が _name_ で型が _value_type_ のカラムを定義
232
232
  * し、新しく定義されたカラムを返す。
233
233
  *
234
- * _options_に指定可能な値は以下の通り。
235
- *
236
- * [+:path+]
234
+ * _options_ に指定可能な値は以下の通り。
235
+ * @param options [::Hash] The name and value
236
+ * pairs. Omitted names are initialized as the default value.
237
+ * @option options :path The path
237
238
  * カラムを保存するパス。
238
239
  *
239
- * [+:persistent+]
240
- * +true+を指定すると永続カラムとなる。省略した場合は永
241
- * 続カラムとなる。+:path+を省略した場合は自動的にパスが
240
+ * @option options :persistent (永続カラム) The persistent
241
+ * +true+ を指定すると永続カラムとなる。省略した場合は永
242
+ * 続カラムとなる。 +:path+ を省略した場合は自動的にパスが
242
243
  * 付加される。
243
244
  *
244
- * [+:type+]
245
+ * @option options :type (:scalar) The type
245
246
  * カラムの値の格納方法について指定する。省略した場合は、
246
- * +:scalar+になる。
247
+ * +:scalar+ になる。
247
248
  *
248
249
  * [+:scalar+] スカラ値(単独の値)を格納する。
249
250
  * [+:vector+] 値の配列を格納する。
250
251
  *
251
- * [+:compress+]
252
+ * @param options :compress The compress
252
253
  * 値の圧縮方法を指定する。省略した場合は、圧縮しない。
253
254
  *
254
255
  * [+:zlib+] 値をzlib圧縮して格納する。
@@ -366,33 +367,34 @@ n_gram_tokenizer_p(grn_ctx *context, grn_obj *tokenizer)
366
367
  * call-seq:
367
368
  * table.define_index_column(name, value_type, options={}) -> Groonga::IndexColumn
368
369
  *
369
- * テーブルに名前が_name_で型が_value_type_のインデックスカ
370
+ * テーブルに名前が _name_ で型が _value_type_ のインデックスカ
370
371
  * ラムを定義し、新しく定義されたカラムを返す。
371
372
  *
372
- * _options_に指定可能な値は以下の通り。
373
- *
374
- * [+:path+]
373
+ * _options_ に指定可能な値は以下の通り。
374
+ * @param options [::Hash] The name and value
375
+ * pairs. Omitted names are initialized as the default value.
376
+ * @option options :path The path
375
377
  * カラムを保存するパス。
376
378
  *
377
- * [+:persistent+]
378
- * +true+を指定すると永続カラムとなる。省略した場合は永
379
- * 続カラムとなる。+:path+を省略した場合は自動的にパスが
379
+ * @option options :persistent (永続カラム) The persistent
380
+ * +true+ を指定すると永続カラムとなる。省略した場合は永
381
+ * 続カラムとなる。 +:path+ を省略した場合は自動的にパスが
380
382
  * 付加される。
381
383
  *
382
- * [+:with_section+]
384
+ * @option options :with_section The with_section
383
385
  * 転置索引にsection(段落情報)を合わせて格納する。
384
386
  *
385
- * [+:with_weight+]
387
+ * @option options :with_weight The with_weight
386
388
  * 転置索引にweight情報を合わせて格納する。
387
389
  *
388
- * [+:with_position+]
390
+ * @option options :with_position The with_position
389
391
  * 転置索引に出現位置情報を合わせて格納する。
390
392
  *
391
- * [+:source+]
392
- * インデックス対象となるカラムを指定する。+:sources+との併用はできない。
393
+ * @option options :source The source
394
+ * インデックス対象となるカラムを指定する。 +:sources+ との併用はできない。
393
395
  *
394
- * [+:sources+]
395
- * インデックス対象となる複数のカラムを指定する。+:source+との併用はできない。
396
+ * @option options :sources The sources
397
+ * インデックス対象となる複数のカラムを指定する。 +:source+ との併用はできない。
396
398
  */
397
399
  static VALUE
398
400
  rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
@@ -521,8 +523,8 @@ ruby_object_to_column_name (VALUE rb_name,
521
523
  * call-seq:
522
524
  * table.column(name) -> Groonga::Column or nil
523
525
  *
524
- * テーブルの_name_に対応するカラムを返す。カラムが存在しな
525
- * い場合は+nil+を返す。
526
+ * テーブルの _name_ に対応するカラムを返す。カラムが存在しな
527
+ * い場合は +nil+ を返す。
526
528
  */
527
529
  VALUE
528
530
  rb_grn_table_get_column (VALUE self, VALUE rb_name)
@@ -602,8 +604,8 @@ rb_grn_table_get_column_surely (VALUE self, VALUE rb_name)
602
604
  * call-seq:
603
605
  * table.columns(name=nil) -> Groonga::Columnの配列
604
606
  *
605
- * テーブルの全てのカラムを返す。_name_が指定された場合はカ
606
- * ラム名の先頭が_name_で始まるカラムを返す。
607
+ * テーブルの全てのカラムを返す。 _name_ が指定された場合はカ
608
+ * ラム名の先頭が _name_ で始まるカラムを返す。
607
609
  */
608
610
  static VALUE
609
611
  rb_grn_table_get_columns (int argc, VALUE *argv, VALUE self)
@@ -670,7 +672,7 @@ rb_grn_table_get_columns (int argc, VALUE *argv, VALUE self)
670
672
  * call-seq:
671
673
  * table.have_column?(name) -> true/false
672
674
  *
673
- * テーブルが_name_カラムを持っている場合は+true+を返す。
675
+ * テーブルが _name_ カラムを持っている場合は +true+ を返す。
674
676
  */
675
677
  static VALUE
676
678
  rb_grn_table_have_column (VALUE self, VALUE rb_name)
@@ -769,43 +771,44 @@ rb_grn_table_open_grn_cursor (int argc, VALUE *argv, VALUE self,
769
771
  * カーソルが破棄される。
770
772
  *
771
773
  * _options_に指定可能な値は以下の通り。
772
- *
773
- * [+:min+]
774
+ * @param options [::Hash] The name and value
775
+ * pairs. Omitted names are initialized as the default value.
776
+ * @option options :min The min
774
777
  * キーの下限
775
778
  *
776
- * [+:max+]
779
+ * @option options :max The max
777
780
  * キーの上限
778
781
  *
779
- * [+:offset+]
780
- * 該当する範囲のレコードのうち、(0ベースで)_:offset_番目
782
+ * @option options :offset The offset
783
+ * 該当する範囲のレコードのうち、(0ベースで) _:offset_ 番目
781
784
  * からレコードを取り出す。
782
785
  *
783
- * [+:limit+]
784
- * 該当する範囲のレコードのうち、_:limit_件のみを取り出す。
786
+ * @option options :limit The limit
787
+ * 該当する範囲のレコードのうち、 _:limit_ 件のみを取り出す。
785
788
  * 省略された場合または-1が指定された場合は、全件が指定され
786
789
  * たものとみなす。
787
790
  *
788
- * [+:order+]
789
- * +:asc+または+:ascending+を指定すると昇順にレコードを取
791
+ * @option options :order (asc) The order
792
+ * +:asc+ または +:ascending+ を指定すると昇順にレコードを取
790
793
  * り出す。(デフォルト)
791
794
  *
792
- * +:desc+または+:descending+を指定すると降順にレコードを
795
+ * +:desc+ または +:descending+ を指定すると降順にレコードを
793
796
  * 取り出す。
794
797
  *
795
- * [+:order_by+]
796
- * +:id+を指定するとID順にレコードを取り出す。(Arrayと
798
+ * @option options :order_by The order_by
799
+ * +:id+ を指定するとID順にレコードを取り出す。(Arrayと
797
800
  * Hashのデフォルト)
798
801
  *
799
- * +:key+指定するとキー順にレコードを取り出す。ただし、
802
+ * +:key+ 指定するとキー順にレコードを取り出す。ただし、
800
803
  * Groonga::PatriciaTrieにしか使えない。(PatriciaTrieのデ
801
804
  * フォルト)
802
805
  *
803
- * [+:greater_than+]
804
- * +true+を指定すると+:min+で指定した値に一致した[+key+]を
806
+ * @option options :greater_than The greater_than
807
+ * +true+ を指定すると +:min+ で指定した値に一致した [ +key+ ]
805
808
  * 範囲に含まない。
806
809
  *
807
- * [+:less_than+]
808
- * +true+を指定すると+:max+で指定した値に一致した[+key+]を
810
+ * @option options :less_than The less_than
811
+ * +true+ を指定すると +:max+ で指定した値に一致した [ +key+ ]
809
812
  * 範囲に含まない。
810
813
  */
811
814
  static VALUE
@@ -874,7 +877,7 @@ rb_grn_table_get_size (VALUE self)
874
877
  * call-seq:
875
878
  * table.empty? -> true/false
876
879
  *
877
- * テーブルにレコードが登録されていなければ+true+を返す。
880
+ * テーブルにレコードが登録されていなければ +true+ を返す。
878
881
  */
879
882
  static VALUE
880
883
  rb_grn_table_empty_p (VALUE self)
@@ -888,7 +891,7 @@ rb_grn_table_empty_p (VALUE self)
888
891
  NULL, NULL, NULL,
889
892
  NULL);
890
893
  size = grn_table_size(context, table);
891
- return size == 0;
894
+ return CBOOL2RVAL(size == 0);
892
895
  }
893
896
 
894
897
  /*
@@ -953,7 +956,7 @@ rb_grn_table_each (VALUE self)
953
956
  * call-seq:
954
957
  * table.delete(id)
955
958
  *
956
- * テーブルの_id_に対応するレコードを削除する。
959
+ * テーブルの _id_ に対応するレコードを削除する。
957
960
  */
958
961
  VALUE
959
962
  rb_grn_table_delete (VALUE self, VALUE rb_id)
@@ -982,41 +985,50 @@ rb_grn_table_delete (VALUE self, VALUE rb_id)
982
985
  * テーブルに登録されているレコードを_keys_で指定されたルー
983
986
  * ルに従ってソートしたレコードの配列を返す。
984
987
  *
985
- * _order_には+:asc+, +:ascending+, +:desc+, +:descending+の
988
+ * _order_ には +:asc+ , +:ascending+ , +:desc+ , +:descending+ の
986
989
  * いずれを指定する。
987
990
  *
988
- * [ハッシュの配列で指定する方法]
989
- * オーソドックスな指定方法。
990
- *
991
- * [
992
- * {:key => "第1ソートキー", :order => order},
993
- * {:key => "第2ソートキー", :order => order},
994
- * ...,
995
- * ]
996
- *
997
- * [配列の配列で指定する方法]
998
- * 少し簡単化した指定方法。
999
- *
1000
- * [
1001
- * ["第1ソートキー", order],
1002
- * ["第2ソートキー", order],
1003
- * ...,
1004
- * ]
1005
- *
1006
- * [ソートキーの配列で指定する方法]
1007
- * _order_は常に昇順(+:ascending+)になるが、最も簡単
1008
- * に指定できる。
1009
- *
1010
- * ["第1ソートキー", "第2ソートキー", ...]
1011
- *
1012
- * _options_に指定可能な値は以下の通り。
1013
- *
1014
- * [+:offset+]
1015
- * ソートされたレコードのうち、(0ベースで)_:offset_番目
991
+ * - ハッシュの配列で指定する方法 :=
992
+ * オーソドックスな指定方法。
993
+ *
994
+ * <pre lang="ruby">
995
+ * [
996
+ * {:key => "第1ソートキー", :order => order},
997
+ * {:key => "第2ソートキー", :order => order},
998
+ * ...,
999
+ * ]
1000
+ * </pre>
1001
+ * =:
1002
+ *
1003
+ * - 配列の配列で指定する方法 :=
1004
+ * 少し簡単化した指定方法。
1005
+ *
1006
+ * <pre lang="ruby">
1007
+ * [
1008
+ * ["第1ソートキー", order],
1009
+ * ["第2ソートキー", order],
1010
+ * ...,
1011
+ * ]
1012
+ * </pre>
1013
+ * =:
1014
+ *
1015
+ * - ソートキーの配列で指定する方法 :=
1016
+ * _order_ は常に昇順( +:ascending+ )になるが、最も簡単
1017
+ * に指定できる。
1018
+ *
1019
+ * <pre lang="ruby">
1020
+ * ["第1ソートキー", "第2ソートキー", ...]
1021
+ * </pre>
1022
+ * =:
1023
+ *
1024
+ * @param options [::Hash] The name and value
1025
+ * pairs. Omitted names are initialized as the default value.
1026
+ * @option options :offset The offset
1027
+ * ソートされたレコードのうち、(0ベースで) _:offset_ 番目
1016
1028
  * からレコードを取り出す。
1017
1029
  *
1018
- * [+:limit+]
1019
- * ソートされたレコードのうち、_:limit_件のみを取り出す。
1030
+ * @option options :limit The limit
1031
+ * ソートされたレコードのうち、 _:limit_ 件のみを取り出す。
1020
1032
  * 省略された場合または-1が指定された場合は、全件が指定され
1021
1033
  * たものとみなす。
1022
1034
  */
@@ -1143,7 +1155,7 @@ rb_grn_table_sort (int argc, VALUE *argv, VALUE self)
1143
1155
  * table.group([key1, key2, ...], options={}) -> [Groonga::Hash, ...]
1144
1156
  * table.group(key, options={}) -> Groonga::Hash
1145
1157
  *
1146
- * _table_のレコードを_key1_, _key2_, _..._で指定したキーの
1158
+ * _table_ のレコードを _key1_ , _key2_ , _..._ で指定したキーの
1147
1159
  * 値でグループ化する。多くの場合、キーにはカラムを指定する。
1148
1160
  * カラムはカラム名(文字列)でも指定可能。
1149
1161
  */
@@ -1244,7 +1256,7 @@ rb_grn_table_group (int argc, VALUE *argv, VALUE self)
1244
1256
  * call-seq:
1245
1257
  * table[id] -> Groonga::Record
1246
1258
  *
1247
- * _table_の_id_に対応するGroonga::Recordを返す。
1259
+ * _table_ _id_ に対応するGroonga::Recordを返す。
1248
1260
  *
1249
1261
  * 0.9.0から値ではなくGroonga::Recordを返すようになった。
1250
1262
  */
@@ -1287,7 +1299,7 @@ rb_grn_table_get_value (VALUE self, VALUE rb_id)
1287
1299
  * table.value(id) -> 値
1288
1300
  * table.value(id, :id => true) -> 値
1289
1301
  *
1290
- * _table_の_id_に対応する値を返す。
1302
+ * _table_ _id_ に対応する値を返す。
1291
1303
  *
1292
1304
  * <tt>:id => true</tt>が指定できるのは利便性のため。
1293
1305
  * Groonga::ArrayでもGroonga::HashやGroonga::PatriciaTrieと
@@ -1347,7 +1359,7 @@ rb_grn_table_set_value (VALUE self, VALUE rb_id, VALUE rb_value)
1347
1359
  * table.set_value(id, value)
1348
1360
  * table.set_value(id, value, :id => true)
1349
1361
  *
1350
- * _table_の_id_に対応する値として_value_設定する。既存の値は
1362
+ * _table_ _id_ に対応する値として _value_ 設定する。既存の値は
1351
1363
  * 上書きされる。
1352
1364
  *
1353
1365
  * <tt>:id => true</tt>が指定できるのは利便性のため。
@@ -1400,7 +1412,7 @@ rb_grn_table_get_column_value (VALUE self, VALUE rb_id, VALUE rb_name)
1400
1412
  * table.column_value(id, name) -> 値
1401
1413
  * table.column_value(id, name, :id => true) -> 値
1402
1414
  *
1403
- * _table_の_id_に対応するカラム_name_の値を返す。
1415
+ * _table_ _id_ に対応するカラム _name_ の値を返す。
1404
1416
  *
1405
1417
  * <tt>:id => true</tt>が指定できるのは利便性のため。
1406
1418
  * Groonga::ArrayでもGroonga::HashやGroonga::PatriciaTrieと
@@ -1456,7 +1468,7 @@ rb_grn_table_set_column_value (VALUE self, VALUE rb_id,
1456
1468
  * table.set_column_value(id, name, value)
1457
1469
  * table.set_column_value(id, name, value, :id => true)
1458
1470
  *
1459
- * _table_の_id_に対応するカラム_name_の値として_value_設定す
1471
+ * _table_ _id_ に対応するカラム _name_ の値として _value_ 設定す
1460
1472
  * る。既存の値は上書きされる。
1461
1473
  *
1462
1474
  * <tt>:id => true</tt>が指定できるのは利便性のため。
@@ -1492,12 +1504,12 @@ rb_grn_table_set_column_value_convenience (int argc, VALUE *argv, VALUE self)
1492
1504
  * call-seq:
1493
1505
  * table.unlock(options={})
1494
1506
  *
1495
- * _table_のロックを解除する。
1507
+ * _table_ のロックを解除する。
1496
1508
  *
1497
1509
  * 利用可能なオプションは以下の通り。
1498
1510
  *
1499
- * [_:id_]
1500
- * _:id_で指定したレコードのロックを解除する。(注:
1511
+ * [ _:id_ ]
1512
+ * _:id_ で指定したレコードのロックを解除する。(注:
1501
1513
  * groonga側が未実装のため、現在は無視される)
1502
1514
  */
1503
1515
  static VALUE
@@ -1543,19 +1555,23 @@ rb_grn_table_unlock_ensure (VALUE self)
1543
1555
  * table.lock(options={})
1544
1556
  * table.lock(options={}) {}
1545
1557
  *
1546
- * _table_をロックする。ロックに失敗した場合は
1558
+ * _table_ をロックする。ロックに失敗した場合は
1547
1559
  * Groonga::ResourceDeadlockAvoided例外が発生する。
1548
1560
  *
1549
1561
  * ブロックを指定した場合はブロックを抜けたときにunlockする。
1550
1562
  *
1551
1563
  * 利用可能なオプションは以下の通り。
1564
+ * @param options [::Hash] The name and value
1565
+ * pairs. Omitted names are initialized as the default value.
1566
+ * @option options :timeout The timeout
1552
1567
  *
1553
- * [_:timeout_]
1554
- * ロックを獲得できなかった場合は_:timeout_秒間ロックの獲
1555
- * 得を試みる。_:timeout_秒以内にロックを獲得できなかった
1568
+ * ロックを獲得できなかった場合は _:timeout_ 秒間ロックの獲
1569
+ * 得を試みる。 _:timeout_ 秒以内にロックを獲得できなかった
1556
1570
  * 場合は例外が発生する。
1557
- * [_:id_]
1558
- * _:id_で指定したレコードをロックする。(注: groonga側が
1571
+ *
1572
+ * @option options :id The id
1573
+ *
1574
+ * _:id_ で指定したレコードをロックする。(注: groonga側が
1559
1575
  * 未実装のため、現在は無視される)
1560
1576
  */
1561
1577
  static VALUE
@@ -1603,12 +1619,14 @@ rb_grn_table_lock (int argc, VALUE *argv, VALUE self)
1603
1619
  * call-seq:
1604
1620
  * table.clear_lock(options={})
1605
1621
  *
1606
- * _table_のロックを強制的に解除する。
1622
+ * _table_ のロックを強制的に解除する。
1607
1623
  *
1608
1624
  * 利用可能なオプションは以下の通り。
1625
+ * @param options [::Hash] The name and value
1626
+ * pairs. Omitted names are initialized as the default value.
1627
+ * @option options :id The id
1609
1628
  *
1610
- * [_:id_]
1611
- * _:id_で指定したレコードのロックを強制的に解除する。
1629
+ * _:id_ で指定したレコードのロックを強制的に解除する。
1612
1630
  * (注: groonga側が未実装のため、現在は無視される。実装さ
1613
1631
  * れるのではないかと思っているが、実装されないかもしれな
1614
1632
  * い。)
@@ -1646,12 +1664,14 @@ rb_grn_table_clear_lock (int argc, VALUE *argv, VALUE self)
1646
1664
  * call-seq:
1647
1665
  * table.locked?(options={})
1648
1666
  *
1649
- * _table_がロックされていれば+true+を返す。
1667
+ * _table_ がロックされていれば +true+ を返す。
1650
1668
  *
1651
1669
  * 利用可能なオプションは以下の通り。
1670
+ * @param options [options] The name and value
1671
+ * pairs. Omitted names are initialized as the default value.
1672
+ * @option options :id The id
1652
1673
  *
1653
- * [_:id_]
1654
- * _:id_で指定したレコードがロックされていれば+true+を返す。
1674
+ * _:id_ で指定したレコードがロックされていれば +true+ を返す。
1655
1675
  * (注: groonga側が未実装のため、現在は無視される。実装さ
1656
1676
  * れるのではないかと思っているが、実装されないかもしれな
1657
1677
  * い。)
@@ -1687,14 +1707,14 @@ rb_grn_table_is_locked (int argc, VALUE *argv, VALUE self)
1687
1707
  * table.select(query, options) -> Groonga::Hash
1688
1708
  * table.select(expression, options) -> Groonga::Hash
1689
1709
  *
1690
- * _table_からブロックまたは文字列で指定した条件にマッチする
1691
- * レコードを返す。返されたテーブルには+expression+という特
1710
+ * _table_ からブロックまたは文字列で指定した条件にマッチする
1711
+ * レコードを返す。返されたテーブルには +expression+ という特
1692
1712
  * 異メソッドがあり、指定した条件を表している
1693
1713
  * Groonga::Expressionを取得できる。
1694
1714
  * Groonga::Expression#snippetを使うことにより、指定した条件
1695
1715
  * 用のスニペットを簡単に生成できる。
1696
- *
1697
- * results = table.select do |record|
1716
+ * <pre>
1717
+ * ==results = table.select do |record|
1698
1718
  * record["description"] =~ "groonga"
1699
1719
  * end
1700
1720
  * snippet = results.expression.snippet([["<em>", "</em>"]])
@@ -1705,65 +1725,72 @@ rb_grn_table_is_locked (int argc, VALUE *argv, VALUE self)
1705
1725
  * puts "#{snippet}..."
1706
1726
  * puts "---"
1707
1727
  * end
1708
- * end
1709
- *
1728
+ * end==
1729
+ * </pre>
1710
1730
  * 出力例
1711
1731
  * Ruby/groongaの説明文の中で「groonga」が含まれる部分
1712
1732
  * ---
1713
1733
  * Ruby/<em>groonga</em>は<em>groonga</em>のいわゆるDB-APIの層の...
1714
1734
  * ---
1715
1735
  *
1716
- * _query_には「[カラム名]:[演算子][値]」という書式で条件を
1736
+ * _query_ には「[カラム名]:[演算子][値]」という書式で条件を
1717
1737
  * 指定する。演算子は以下の通り。
1718
- *
1719
- * [なし]
1720
- * \[カラム値] == [値]
1721
- * [<tt>!</tt>]
1722
- * \[カラム値] != [値]
1723
- * [<tt><</tt>]
1724
- * \[カラム値] < [値]
1725
- * [<tt>></tt>]
1726
- * \[カラム値] > [値]
1727
- * [<tt><=</tt>]
1728
- * \[カラム値] <= [値]
1729
- * [<tt>>=</tt>]
1730
- * \[カラム値] >= [値]
1731
- * [<tt>@</tt>]
1732
- * \[カラム値]が[値]を含んでいるかどうか
1738
+ * <pre>
1739
+ * [なし]
1740
+ * \[カラム値] == [値]
1741
+ * [<tt>!</tt>]
1742
+ * \[カラム値] != [値]
1743
+ * [<tt><</tt>]
1744
+ * \[カラム値] < [値]
1745
+ * [<tt>></tt>]
1746
+ * \[カラム値] > [値]
1747
+ * [<tt><=</tt>]
1748
+ * \[カラム値] <= [値]
1749
+ * [<tt>>=</tt>]
1750
+ * \[カラム値] >= [値]
1751
+ * [<tt>@</tt>]
1752
+ * \[カラム値]が[値]を含んでいるかどうか
1753
+ * </pre>
1733
1754
  *
1734
1755
  * 例:
1735
- * "name:daijiro" # "name"カラムの値が"daijiro"のレコードにマッチ
1756
+ * <pre>
1757
+ * =="name:daijiro" # "name"カラムの値が"daijiro"のレコードにマッチ
1736
1758
  * "description:@groonga" # "description"カラムが
1737
- * # "groonga"を含んでいるレコードにマッチ
1759
+ * # "groonga"を含んでいるレコードにマッチ==
1760
+ * </pre>
1738
1761
  *
1739
- * _expression_には既に作成済みのGroonga::Expressionを渡す
1762
+ * _expression_ には既に作成済みのGroonga::Expressionを渡す
1740
1763
  *
1741
1764
  * ブロックで条件を指定する場合は
1742
1765
  * Groonga::RecordExpressionBuilderを参照。
1743
1766
  *
1744
1767
  * Ruby1.9以降では、ブロックで条件を指定する際に
1745
1768
  * Groonga::ColumnExpressionBuilderの他に"!="も使用可能。
1769
+ *
1746
1770
  * 例:
1747
- * comments = Groonga::Array.create(:name => "Comments")
1771
+ * <pre>
1772
+ * ==comments = Groonga::Array.create(:name => "Comments")
1748
1773
  * comments.define_column("content", "Text")
1749
- *
1750
1774
  * comments.add(:content => "Hello Good-bye!")
1751
1775
  * comments.add(:content => "Hello World")
1752
1776
  * comments.add(:content => "test")
1753
- *
1754
1777
  * result = comments.select do |record|
1755
1778
  * record.content != "test"
1756
1779
  * end
1757
1780
  * p result.collect {|record| record.content}
1758
- * # => ["Hello Good-bye!", "Hello World"]
1781
+ * # => ["Hello Good-bye!", "Hello World"]==
1782
+ * </pre>
1759
1783
  *
1760
- * _options_に指定可能な値は以下の通り。
1784
+ * _options_ に指定可能な値は以下の通り。
1785
+ * @param options [::Hash] The name and value
1786
+ * pairs. Omitted names are initialized as the default value.
1787
+ * @option options :default_column
1761
1788
  *
1762
- * [+:default_column+]
1763
1789
  * "column_name:hoge"ではなく"hoge"のようにcolumn_nameが指
1764
1790
  * 定されない条件の検索対象となるカラムを指定する。
1765
1791
  *
1766
- * [+:operator+]
1792
+ * @option options :operator (Groonga::Operator::OR) The operator
1793
+ *
1767
1794
  * マッチしたレコードをどのように扱うか。指定可能な値は以
1768
1795
  * 下の通り。省略した場合はGroonga::Operator::OR。
1769
1796
  *
@@ -1777,31 +1804,37 @@ rb_grn_table_is_locked (int argc, VALUE *argv, VALUE self)
1777
1804
  * [Groonga::Operator::ADJUST] マッチしたレコードのスコア
1778
1805
  * を増加。
1779
1806
  *
1780
- * [+:result+]
1807
+ * @option options :result The result
1808
+ *
1781
1809
  * 検索結果を格納するテーブル。マッチしたレコードが追加さ
1782
1810
  * れていく。省略した場合は新しくテーブルを作成して返す。
1783
1811
  *
1784
- * [+:name+]
1812
+ * @option options :name The name
1813
+ *
1785
1814
  * 条件の名前。省略した場合は名前を付けない。
1786
1815
  *
1787
- * [+:syntax+]
1788
- * _query_の構文。省略した場合は+:query+。
1816
+ * @option options :syntax The syntax
1817
+ *
1818
+ * _query_ の構文。省略した場合は +:query+ 。
1789
1819
  *
1790
1820
  * 参考: Groonga::Expression#parse.
1791
1821
  *
1792
- * [+:allow_pragma+]
1822
+ * @option options :allow_pragma The allow_pragma
1823
+ *
1793
1824
  * query構文時にプラグマを利用するかどうか。省略した場合は
1794
1825
  * 利用する。
1795
1826
  *
1796
1827
  * 参考: Groonga::Expression#parse.
1797
1828
  *
1798
- * [+:allow_column+]
1829
+ * @option options :allow_column The allow_column
1830
+ *
1799
1831
  * query構文時にカラム指定を利用するかどうか。省略した場合
1800
1832
  * は利用する。
1801
1833
  *
1802
1834
  * 参考: Groonga::Expression#parse.
1803
1835
  *
1804
- * [+:allow_update+]
1836
+ * @option options :allow_update The allow_update
1837
+ *
1805
1838
  * script構文時に更新操作を利用するかどうか。省略した場合
1806
1839
  * は利用する。
1807
1840
  *
@@ -1918,8 +1951,8 @@ rb_grn_table_set_operation_bang (VALUE self, VALUE rb_other,
1918
1951
  * call-seq:
1919
1952
  * table.union!(other) -> Groonga::Table
1920
1953
  *
1921
- * キーを比較し、_table_には登録されていない_other_のレコー
1922
- * ドを_table_に作成する。
1954
+ * キーを比較し、 _table_ には登録されていない _other_ のレコー
1955
+ * ドを _table_ に作成する。
1923
1956
  *
1924
1957
  */
1925
1958
  static VALUE
@@ -1933,8 +1966,8 @@ rb_grn_table_union_bang (VALUE self, VALUE rb_other)
1933
1966
  * call-seq:
1934
1967
  * table.intersection!(other) -> Groonga::Table
1935
1968
  *
1936
- * キーを比較し、_other_には登録されていないレコードを
1937
- * _table_から削除する。
1969
+ * キーを比較し、 _other_ には登録されていないレコードを
1970
+ * _table_ から削除する。
1938
1971
  *
1939
1972
  */
1940
1973
  static VALUE
@@ -1947,7 +1980,7 @@ rb_grn_table_intersection_bang (VALUE self, VALUE rb_other)
1947
1980
  * call-seq:
1948
1981
  * table.difference!(other) -> Groonga::Table
1949
1982
  *
1950
- * キーを比較し、_other_にも登録されているレコードを_table_
1983
+ * キーを比較し、 _other_ にも登録されているレコードを _table_
1951
1984
  * から削除する。
1952
1985
  *
1953
1986
  */
@@ -1961,8 +1994,8 @@ rb_grn_table_difference_bang (VALUE self, VALUE rb_other)
1961
1994
  * call-seq:
1962
1995
  * table.merge!(other) -> Groonga::Table
1963
1996
  *
1964
- * キーを比較し、_other_にも登録されている_table_のレコード
1965
- * のスコアを_other_のスコアと同値にする。
1997
+ * キーを比較し、 _other_ にも登録されている _table_ のレコード
1998
+ * のスコアを _other_ のスコアと同値にする。
1966
1999
  *
1967
2000
  */
1968
2001
  static VALUE
@@ -1975,8 +2008,8 @@ rb_grn_table_merge_bang (VALUE self, VALUE rb_other)
1975
2008
  * call-seq:
1976
2009
  * table.support_key? -> true/false
1977
2010
  *
1978
- * _table_に主キーが設定されていれば+true+、されていなければ
1979
- * +false+を返す。
2011
+ * _table_ に主キーが設定されていれば +true+ 、されていなければ
2012
+ * +false+ を返す。
1980
2013
  */
1981
2014
  static VALUE
1982
2015
  rb_grn_table_support_key_p (VALUE self)
@@ -1989,7 +2022,7 @@ rb_grn_table_support_key_p (VALUE self)
1989
2022
  * table.support_sub_records? -> true/false
1990
2023
  *
1991
2024
  * グループ化したとき、テーブルにグループに含まれるレコード
1992
- * 数を格納できる場合は+true+、格納できない場合は+false+を返
2025
+ * 数を格納できる場合は +true+ 、格納できない場合は +false+ を返
1993
2026
  * す。
1994
2027
  */
1995
2028
  static VALUE
@@ -2008,8 +2041,8 @@ rb_grn_table_support_sub_records_p (VALUE self)
2008
2041
  * call-seq:
2009
2042
  * table.exist?(id) -> true/false
2010
2043
  *
2011
- * _table_に_id_で指定したIDのレコードが存在する場合は+true+、
2012
- * 存在しない場合は+false+を返す。
2044
+ * _table_ _id_ で指定したIDのレコードが存在する場合は +true+ 、
2045
+ * 存在しない場合は +false+ を返す。
2013
2046
  *
2014
2047
  * 注意: 実行には相応のコストがかかるのであまり頻繁に呼ばな
2015
2048
  * いようにして下さい。
@@ -2027,6 +2060,83 @@ rb_grn_table_exist_p (VALUE self, VALUE id)
2027
2060
  return CBOOL2RVAL(grn_table_at(context, table, NUM2UINT(id)));
2028
2061
  }
2029
2062
 
2063
+ /*
2064
+ * Document-method: defrag
2065
+ *
2066
+ * call-seq:
2067
+ * table.defrag(options={}) -> n_segments
2068
+ *
2069
+ * Defrags all variable size columns in the table.
2070
+ *
2071
+ * @return [Integer] the number of defraged segments
2072
+ * @option options [Integer] :threshold (0) the threshold to
2073
+ * determine whether a segment is defraged. Available
2074
+ * values are -4..22. -4 means all segments are defraged.
2075
+ * 22 means no segment is defraged.
2076
+ * @since 1.3.0
2077
+ */
2078
+ static VALUE
2079
+ rb_grn_table_defrag (int argc, VALUE *argv, VALUE self)
2080
+ {
2081
+ grn_ctx *context;
2082
+ grn_obj *table;
2083
+ int n_segments;
2084
+ VALUE options, rb_threshold;
2085
+ int threshold = 0;
2086
+
2087
+ rb_scan_args(argc, argv, "01", &options);
2088
+ rb_grn_scan_options(options,
2089
+ "threshold", &rb_threshold,
2090
+ NULL);
2091
+ if (!NIL_P(rb_threshold)) {
2092
+ threshold = NUM2INT(rb_threshold);
2093
+ }
2094
+
2095
+ rb_grn_table_deconstruct(SELF(self), &table, &context,
2096
+ NULL, NULL, NULL,
2097
+ NULL, NULL,
2098
+ NULL);
2099
+ n_segments = grn_obj_defrag(context, table, threshold);
2100
+ rb_grn_context_check(context, self);
2101
+
2102
+ return INT2NUM(n_segments);
2103
+ }
2104
+
2105
+ /*
2106
+ * Document-method: rename
2107
+ *
2108
+ * call-seq:
2109
+ * table.rename(name)
2110
+ *
2111
+ * Renames the table to name.
2112
+ *
2113
+ * @param name [String] the new name
2114
+ * @since 1.3.0
2115
+ */
2116
+ static VALUE
2117
+ rb_grn_table_rename (VALUE self, VALUE rb_name)
2118
+ {
2119
+ int rc;
2120
+ grn_ctx *context;
2121
+ grn_obj *table;
2122
+ char *name;
2123
+ int name_size;
2124
+
2125
+ rb_grn_table_deconstruct(SELF(self), &table, &context,
2126
+ NULL, NULL, NULL,
2127
+ NULL, NULL,
2128
+ NULL);
2129
+
2130
+ name = StringValueCStr(rb_name);
2131
+ name_size = RSTRING_LEN(rb_name);
2132
+
2133
+ rc = grn_table_rename(context, table, name, name_size);
2134
+ rb_grn_context_check(context, self);
2135
+ rb_grn_rc_check(rc, self);
2136
+
2137
+ return self;
2138
+ }
2139
+
2030
2140
  void
2031
2141
  rb_grn_init_table (VALUE mGrn)
2032
2142
  {
@@ -2101,9 +2211,14 @@ rb_grn_init_table (VALUE mGrn)
2101
2211
 
2102
2212
  rb_define_method(rb_cGrnTable, "exist?", rb_grn_table_exist_p, 1);
2103
2213
 
2214
+ rb_define_method(rb_cGrnTable, "defrag", rb_grn_table_defrag, -1);
2215
+
2216
+ rb_define_method(rb_cGrnTable, "rename", rb_grn_table_rename, 1);
2217
+
2104
2218
  rb_grn_init_table_key_support(mGrn);
2105
2219
  rb_grn_init_array(mGrn);
2106
2220
  rb_grn_init_hash(mGrn);
2107
2221
  rb_grn_init_patricia_trie(mGrn);
2222
+ rb_grn_init_double_array_trie(mGrn);
2108
2223
  rb_grn_init_view(mGrn);
2109
2224
  }