rroonga 2.0.4 → 2.0.5
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.
- data/Rakefile +21 -2
- data/bin/grndump +3 -2
- data/ext/groonga/extconf.rb +1 -6
- data/ext/groonga/rb-grn-array.c +58 -31
- data/ext/groonga/rb-grn-column.c +220 -148
- data/ext/groonga/rb-grn-context.c +46 -32
- data/ext/groonga/rb-grn-database.c +102 -90
- data/ext/groonga/rb-grn-double-array-trie.c +205 -163
- data/ext/groonga/rb-grn-encoding-support.c +2 -3
- data/ext/groonga/rb-grn-encoding.c +13 -8
- data/ext/groonga/rb-grn-exception.c +1 -1
- data/ext/groonga/rb-grn-expression.c +110 -133
- data/ext/groonga/rb-grn-fix-size-column.c +5 -4
- data/ext/groonga/rb-grn-geo-point.c +55 -0
- data/ext/groonga/rb-grn-hash.c +120 -82
- data/ext/groonga/rb-grn-index-column.c +66 -70
- data/ext/groonga/rb-grn-index-cursor.c +3 -0
- data/ext/groonga/rb-grn-logger.c +33 -51
- data/ext/groonga/rb-grn-object.c +2 -0
- data/ext/groonga/rb-grn-operator.c +1 -1
- data/ext/groonga/rb-grn-patricia-trie.c +287 -232
- data/ext/groonga/rb-grn-plugin.c +11 -14
- data/ext/groonga/rb-grn-snippet.c +37 -54
- data/ext/groonga/rb-grn-table-cursor-key-support.c +3 -3
- data/ext/groonga/rb-grn-table-cursor.c +8 -6
- data/ext/groonga/rb-grn-table-key-support.c +22 -29
- data/ext/groonga/rb-grn-table.c +355 -279
- data/ext/groonga/rb-grn-type.c +18 -25
- data/ext/groonga/rb-grn-utils.c +77 -7
- data/ext/groonga/rb-grn-variable-size-column.c +12 -20
- data/ext/groonga/rb-grn-view.c +56 -51
- data/ext/groonga/rb-grn.h +28 -1
- data/ext/groonga/rb-groonga.c +1 -0
- data/lib/groonga.rb +2 -0
- data/lib/groonga/command.rb +3 -1
- data/lib/groonga/database.rb +27 -0
- data/lib/groonga/dumper.rb +96 -17
- data/lib/groonga/geo-point.rb +216 -0
- data/lib/groonga/schema.rb +29 -46
- data/rroonga-build.rb +1 -1
- data/rroonga.gemspec +90 -0
- data/test/groonga-test-utils.rb +168 -0
- data/test/run-test.rb +60 -0
- data/test/test-accessor.rb +36 -0
- data/test/test-array.rb +146 -0
- data/test/test-column.rb +350 -0
- data/test/test-command-select.rb +181 -0
- data/test/test-context.rb +130 -0
- data/test/test-database-dumper.rb +259 -0
- data/test/test-database.rb +173 -0
- data/test/test-double-array-trie.rb +189 -0
- data/test/test-encoding.rb +33 -0
- data/test/test-exception.rb +230 -0
- data/test/test-expression-builder.rb +602 -0
- data/test/test-expression.rb +134 -0
- data/test/test-fix-size-column.rb +77 -0
- data/test/test-geo-point.rb +190 -0
- data/test/test-gqtp.rb +70 -0
- data/test/test-hash.rb +367 -0
- data/test/test-index-column.rb +180 -0
- data/test/test-index-cursor.rb +123 -0
- data/test/test-logger.rb +37 -0
- data/test/test-pagination.rb +249 -0
- data/test/test-patricia-trie.rb +440 -0
- data/test/test-plugin.rb +35 -0
- data/test/test-procedure.rb +37 -0
- data/test/test-query-log.rb +258 -0
- data/test/test-record.rb +577 -0
- data/test/test-remote.rb +63 -0
- data/test/test-schema-create-table.rb +267 -0
- data/test/test-schema-dumper.rb +235 -0
- data/test/test-schema-type.rb +208 -0
- data/test/test-schema-view.rb +90 -0
- data/test/test-schema.rb +886 -0
- data/test/test-snippet.rb +130 -0
- data/test/test-table-dumper.rb +353 -0
- data/test/test-table-offset-and-limit.rb +100 -0
- data/test/test-table-select-mecab.rb +80 -0
- data/test/test-table-select-normalize.rb +57 -0
- data/test/test-table-select-weight.rb +123 -0
- data/test/test-table-select.rb +191 -0
- data/test/test-table-traverse.rb +304 -0
- data/test/test-table.rb +711 -0
- data/test/test-type.rb +79 -0
- data/test/test-variable-size-column.rb +147 -0
- data/test/test-variable.rb +28 -0
- data/test/test-vector-column.rb +76 -0
- data/test/test-version.rb +61 -0
- data/test/test-view.rb +72 -0
- metadata +330 -202
@@ -399,17 +399,13 @@ rb_grn_context_s_set_default_options (VALUE self, VALUE options)
|
|
399
399
|
}
|
400
400
|
|
401
401
|
/*
|
402
|
-
*
|
403
|
-
*
|
404
|
-
*
|
405
|
-
*
|
406
|
-
*
|
407
|
-
*
|
408
|
-
*
|
409
|
-
* @option options :encoding The encoding
|
410
|
-
*
|
411
|
-
* エンコーディングを指定する。エンコーディングの指定方法
|
412
|
-
* はGroonga::Encodingを参照。
|
402
|
+
* コンテキストを作成する。
|
403
|
+
* @overload new(options=nil)
|
404
|
+
* @param [::Hash] options The name and value
|
405
|
+
* pairs. Omitted names are initialized as the default value.
|
406
|
+
* @option options [Groonga::Encoding] :encoding The encoding
|
407
|
+
* エンコーディングを指定する。エンコーディングの指定方法
|
408
|
+
* はGroonga::Encodingを参照。
|
413
409
|
*/
|
414
410
|
static VALUE
|
415
411
|
rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
|
@@ -570,6 +566,28 @@ rb_grn_context_set_encoding (VALUE self, VALUE rb_encoding)
|
|
570
566
|
return rb_encoding;
|
571
567
|
}
|
572
568
|
|
569
|
+
/*
|
570
|
+
* Gets the encoding used by the context as Ruby's encoding object.
|
571
|
+
*
|
572
|
+
* @overload ruby_encoding
|
573
|
+
*
|
574
|
+
* @return [::Encoding] the encoding used by the context
|
575
|
+
*
|
576
|
+
* @since 2.0.5
|
577
|
+
*/
|
578
|
+
static VALUE
|
579
|
+
rb_grn_context_get_ruby_encoding (VALUE self)
|
580
|
+
{
|
581
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
582
|
+
grn_encoding encoding;
|
583
|
+
|
584
|
+
encoding = GRN_CTX_GET_ENCODING(SELF(self));
|
585
|
+
return rb_grn_encoding_to_ruby_encoding_object(encoding);
|
586
|
+
#else
|
587
|
+
return Qnil;
|
588
|
+
#endif
|
589
|
+
}
|
590
|
+
|
573
591
|
/*
|
574
592
|
* call-seq:
|
575
593
|
* context.match_escalation_threshold -> Integer
|
@@ -667,21 +685,15 @@ rb_grn_context_get_database (VALUE self)
|
|
667
685
|
}
|
668
686
|
|
669
687
|
/*
|
670
|
-
*
|
671
|
-
*
|
672
|
-
*
|
673
|
-
*
|
674
|
-
*
|
675
|
-
*
|
676
|
-
*
|
677
|
-
*
|
678
|
-
*
|
679
|
-
* groongaサーバのホスト名。またはIPアドレス。省略すると
|
680
|
-
* "localhost"に接続する。
|
681
|
-
* @option options :port (10041) The port number
|
682
|
-
*
|
683
|
-
* groongaサーバのポート番号。省略すると10041番ポートに接
|
684
|
-
* 続する。
|
688
|
+
* groongaサーバに接続する。
|
689
|
+
* @overload connect(options=nil)
|
690
|
+
* @param [::Hash] options 利用可能なオプションは次の通り。
|
691
|
+
* @option options :host (localhost)
|
692
|
+
* groongaサーバのホスト名。またはIPアドレス。省略すると
|
693
|
+
* "localhost"に接続する。
|
694
|
+
* @option options :port (10041)
|
695
|
+
* groongaサーバのポート番号。省略すると10041番ポートに接
|
696
|
+
* 続する。
|
685
697
|
*/
|
686
698
|
static VALUE
|
687
699
|
rb_grn_context_connect (int argc, VALUE *argv, VALUE self)
|
@@ -721,10 +733,10 @@ rb_grn_context_connect (int argc, VALUE *argv, VALUE self)
|
|
721
733
|
}
|
722
734
|
|
723
735
|
/*
|
724
|
-
* call-seq:
|
725
|
-
* context.send(string) -> ID
|
726
|
-
*
|
727
736
|
* groongaサーバにクエリ文字列を送信する。
|
737
|
+
* @return [Integer] ID
|
738
|
+
* @overload send(string)
|
739
|
+
* @param [String] string クエリ文字列
|
728
740
|
*/
|
729
741
|
static VALUE
|
730
742
|
rb_grn_context_send (VALUE self, VALUE rb_string)
|
@@ -745,10 +757,9 @@ rb_grn_context_send (VALUE self, VALUE rb_string)
|
|
745
757
|
}
|
746
758
|
|
747
759
|
/*
|
748
|
-
* call-seq:
|
749
|
-
* context.receive -> [ID, String]
|
750
|
-
*
|
751
760
|
* groongaサーバからクエリ実行結果文字列を受信する。
|
761
|
+
* @overload receive
|
762
|
+
* @return [[ID, String]] クエリ実行結果
|
752
763
|
*/
|
753
764
|
static VALUE
|
754
765
|
rb_grn_context_receive (VALUE self)
|
@@ -889,6 +900,7 @@ rb_grn_context_array_reference (VALUE self, VALUE name_or_id)
|
|
889
900
|
rb_grn_inspect(name_or_id));
|
890
901
|
break;
|
891
902
|
}
|
903
|
+
rb_grn_context_check(context, name_or_id);
|
892
904
|
|
893
905
|
return GRNOBJECT2RVAL(Qnil, context, object, GRN_FALSE);
|
894
906
|
}
|
@@ -920,6 +932,8 @@ rb_grn_init_context (VALUE mGrn)
|
|
920
932
|
|
921
933
|
rb_define_method(cGrnContext, "encoding", rb_grn_context_get_encoding, 0);
|
922
934
|
rb_define_method(cGrnContext, "encoding=", rb_grn_context_set_encoding, 1);
|
935
|
+
rb_define_method(cGrnContext, "ruby_encoding",
|
936
|
+
rb_grn_context_get_ruby_encoding, 0);
|
923
937
|
rb_define_method(cGrnContext, "match_escalation_threshold",
|
924
938
|
rb_grn_context_get_match_escalation_threshold, 0);
|
925
939
|
rb_define_method(cGrnContext, "match_escalation_threshold=",
|
@@ -164,29 +164,24 @@ reset_floating_objects (VALUE rb_context)
|
|
164
164
|
}
|
165
165
|
|
166
166
|
/*
|
167
|
-
* call-seq:
|
168
|
-
* Groonga::Database.create(options=nil) -> Groonga::Database
|
169
|
-
*
|
170
167
|
* 新しくデータベースを作成する。
|
171
|
-
*
|
172
|
-
*
|
173
|
-
*
|
174
|
-
*
|
175
|
-
*
|
176
|
-
*
|
177
|
-
*
|
178
|
-
*
|
179
|
-
*
|
180
|
-
*
|
181
|
-
*
|
182
|
-
* データベースを結びつけるコンテキスト。省略すると
|
183
|
-
* Groonga::Context.defaultを利用する。
|
168
|
+
* _options_ にはハッシュでオプションを指定する。
|
169
|
+
* @return [Groonga::Database] 作成されたデータベース
|
170
|
+
* @overload create(options=nil)
|
171
|
+
* @param option [::Hash] options The name and value
|
172
|
+
* pairs. Omitted names are initialized as the default value.
|
173
|
+
* @option options :path
|
174
|
+
* データベースを保存するパス。省略すると一時データベース
|
175
|
+
* となる。
|
176
|
+
* @option options :context (Groonga::Context.default)
|
177
|
+
* データベースを結びつけるコンテキスト。省略すると
|
178
|
+
* Groonga::Context.defaultを利用する。
|
184
179
|
*
|
185
180
|
* @example
|
186
|
-
* 一時データベースを作成:
|
181
|
+
* # 一時データベースを作成:
|
187
182
|
* Groonga::Database.create
|
188
183
|
*
|
189
|
-
* 永続データベースを作成:
|
184
|
+
* # 永続データベースを作成:
|
190
185
|
* Groonga::Database.create(:path => "/tmp/db.groonga")
|
191
186
|
*/
|
192
187
|
static VALUE
|
@@ -236,22 +231,24 @@ rb_grn_database_s_create (int argc, VALUE *argv, VALUE klass)
|
|
236
231
|
}
|
237
232
|
|
238
233
|
/*
|
239
|
-
* call-seq:
|
240
|
-
* Groonga::Database.new(path, options=nil) -> Groonga::Database
|
241
|
-
* Groonga::Database.new(path, options=nil) {|database| ...}
|
242
|
-
*
|
243
234
|
* 既存のデータベースを開く。ブロックを指定した場合はブロッ
|
244
235
|
* クに開いたデータベースを渡し、ブロックを抜けるときに閉じ
|
245
236
|
* る。
|
246
|
-
*
|
247
|
-
*
|
248
|
-
*
|
249
|
-
*
|
250
|
-
*
|
251
|
-
*
|
252
|
-
*
|
253
|
-
*
|
254
|
-
*
|
237
|
+
* @overload new(path, options=nil)
|
238
|
+
* @param options [::Hash] The name and value
|
239
|
+
* pairs. Omitted names are initialized as the default value.
|
240
|
+
* @option options :context (Groonga::Context.default)
|
241
|
+
* データベースを結びつけるコンテキスト。省略すると
|
242
|
+
* Groonga::Context.defaultを利用する。
|
243
|
+
* @return [Groonga::Database]
|
244
|
+
* @overload new(path, options=nil)
|
245
|
+
* @param options [::Hash] The name and value
|
246
|
+
* pairs. Omitted names are initialized as the default value.
|
247
|
+
* @option options :context (Groonga::Context.default)
|
248
|
+
* データベースを結びつけるコンテキスト。省略すると
|
249
|
+
* Groonga::Context.defaultを利用する。
|
250
|
+
* @yield [database]
|
251
|
+
* @yieldparam [Groonga::Database] database 開いたデータベース
|
255
252
|
*/
|
256
253
|
static VALUE
|
257
254
|
rb_grn_database_initialize (int argc, VALUE *argv, VALUE self)
|
@@ -286,21 +283,22 @@ rb_grn_database_initialize (int argc, VALUE *argv, VALUE self)
|
|
286
283
|
}
|
287
284
|
|
288
285
|
/*
|
289
|
-
* call-seq:
|
290
|
-
* Groonga::Database.open(path, options=nil) -> Groonga::Database
|
291
|
-
* Groonga::Database.open(path, options=nil) {|database| ...}
|
292
|
-
*
|
293
286
|
* 既存のデータベースを開く。ブロックを指定した場合はブロッ
|
294
287
|
* クに開いたデータベースを渡し、ブロックを抜けるときに閉じ
|
295
|
-
* る。
|
296
|
-
*
|
297
|
-
*
|
298
|
-
*
|
299
|
-
*
|
300
|
-
*
|
301
|
-
*
|
302
|
-
*
|
303
|
-
*
|
288
|
+
* る。 _options_ にはハッシュでオプションを指定する。
|
289
|
+
* @overload open(path, options=nil)
|
290
|
+
* @return [Groonga::Database]
|
291
|
+
* @param options [::Hash] The name and value
|
292
|
+
* pairs. Omitted names are initialized as the default value.
|
293
|
+
* @option options :context (Groonga::Context.default) The context
|
294
|
+
* データベースを結びつけるコンテキスト。
|
295
|
+
* @overload open(path, options=nil)
|
296
|
+
* @param options [::Hash] The name and value
|
297
|
+
* pairs. Omitted names are initialized as the default value.
|
298
|
+
* @option options :context (Groonga::Context.default) The context
|
299
|
+
* データベースを結びつけるコンテキスト。
|
300
|
+
* @yield [database]
|
301
|
+
* @yieldparam [Groonga::Database] database 開いたデータベース
|
304
302
|
*/
|
305
303
|
static VALUE
|
306
304
|
rb_grn_database_s_open (int argc, VALUE *argv, VALUE klass)
|
@@ -316,12 +314,7 @@ rb_grn_database_s_open (int argc, VALUE *argv, VALUE klass)
|
|
316
314
|
}
|
317
315
|
|
318
316
|
/*
|
319
|
-
* call-seq:
|
320
|
-
* database.each {|object| ...}
|
321
|
-
* database.each(options=nil) {|object| ...}
|
322
|
-
*
|
323
317
|
* データベース内のオブジェクトを順番にブロックに渡す。
|
324
|
-
*
|
325
318
|
* @example すべてのオブジェクトの名前を表示する:
|
326
319
|
* database.each do |object|
|
327
320
|
* p object.name
|
@@ -337,20 +330,28 @@ rb_grn_database_s_open (int argc, VALUE *argv, VALUE klass)
|
|
337
330
|
* p object.name
|
338
331
|
* end
|
339
332
|
*
|
340
|
-
* @
|
341
|
-
*
|
342
|
-
*
|
343
|
-
*
|
344
|
-
*
|
345
|
-
*
|
346
|
-
*
|
347
|
-
*
|
348
|
-
*
|
349
|
-
*
|
350
|
-
*
|
351
|
-
*
|
352
|
-
*
|
353
|
-
*
|
333
|
+
* @overload each(options=nil)
|
334
|
+
* @macro [new] database.each.options
|
335
|
+
* @param options [::Hash]
|
336
|
+
* @yield [object]
|
337
|
+
* @option options :order
|
338
|
+
* +:asc+ または +:ascending+ を指定すると昇順にレコードを取
|
339
|
+
* り出す。(デフォルト)
|
340
|
+
* +:desc+ または +:descending+ を指定すると降順にレコードを
|
341
|
+
* 取り出す。
|
342
|
+
* @option options :order_by (:key)
|
343
|
+
* +:id+ を指定するとID順にレコードを取り出す。
|
344
|
+
* +:key+ 指定するとキー順にレコードを取り出す。(デフォル
|
345
|
+
* ト)
|
346
|
+
* @macro database.each.options
|
347
|
+
*
|
348
|
+
* @overload each(options=nil)
|
349
|
+
* @macro database.each.options
|
350
|
+
* @option options :ignore_missing_object (false)
|
351
|
+
* Specify +true+ to ignore missing object. Otherwise, an exception is
|
352
|
+
* raised for missing object.
|
353
|
+
*
|
354
|
+
* @since 2.0.5
|
354
355
|
*/
|
355
356
|
static VALUE
|
356
357
|
rb_grn_database_each (int argc, VALUE *argv, VALUE self)
|
@@ -359,8 +360,12 @@ rb_grn_database_each (int argc, VALUE *argv, VALUE self)
|
|
359
360
|
grn_obj *database;
|
360
361
|
grn_table_cursor *cursor;
|
361
362
|
VALUE rb_cursor, rb_options, rb_order, rb_order_by;
|
363
|
+
VALUE rb_ignore_missing_object;
|
362
364
|
int flags = 0;
|
363
365
|
grn_id id;
|
366
|
+
VALUE exception;
|
367
|
+
|
368
|
+
RETURN_ENUMERATOR(self, argc, argv);
|
364
369
|
|
365
370
|
rb_grn_database_deconstruct(SELF(self), &database, &context,
|
366
371
|
NULL, NULL, NULL, NULL);
|
@@ -370,6 +375,7 @@ rb_grn_database_each (int argc, VALUE *argv, VALUE self)
|
|
370
375
|
rb_grn_scan_options(rb_options,
|
371
376
|
"order", &rb_order,
|
372
377
|
"order_by", &rb_order_by,
|
378
|
+
"ignore_missing_object", &rb_ignore_missing_object,
|
373
379
|
NULL);
|
374
380
|
|
375
381
|
flags |= rb_grn_table_cursor_order_to_flag(rb_order);
|
@@ -386,8 +392,21 @@ rb_grn_database_each (int argc, VALUE *argv, VALUE self)
|
|
386
392
|
grn_obj *object;
|
387
393
|
|
388
394
|
object = grn_ctx_at(context, id);
|
389
|
-
if (object)
|
395
|
+
if (!object && RTEST(rb_ignore_missing_object)) {
|
396
|
+
context->rc = GRN_SUCCESS;
|
397
|
+
continue;
|
398
|
+
}
|
399
|
+
|
400
|
+
exception = rb_grn_context_to_exception(context, self);
|
401
|
+
if (!NIL_P(exception)) {
|
402
|
+
rb_grn_object_close(rb_cursor);
|
403
|
+
rb_iv_set(self, "cursor", Qnil);
|
404
|
+
rb_exc_raise(exception);
|
405
|
+
}
|
406
|
+
|
407
|
+
if (object) {
|
390
408
|
rb_yield(GRNOBJECT2RVAL(Qnil, context, object, GRN_FALSE));
|
409
|
+
}
|
391
410
|
}
|
392
411
|
rb_grn_object_close(rb_cursor);
|
393
412
|
rb_iv_set(self, "cursor", Qnil);
|
@@ -421,25 +440,22 @@ rb_grn_database_unlock (VALUE self)
|
|
421
440
|
}
|
422
441
|
|
423
442
|
/*
|
424
|
-
* Document-method: lock
|
425
|
-
*
|
426
|
-
* call-seq:
|
427
|
-
* database.lock(options={})
|
428
|
-
* database.lock(options={}) {...}
|
429
|
-
*
|
430
443
|
* _database_ をロックする。ロックに失敗した場合は
|
431
444
|
* Groonga::ResourceDeadlockAvoided例外が発生する。
|
432
445
|
*
|
433
|
-
*
|
434
|
-
*
|
435
|
-
*
|
436
|
-
*
|
437
|
-
*
|
438
|
-
*
|
439
|
-
*
|
440
|
-
*
|
441
|
-
*
|
442
|
-
*
|
446
|
+
* @overload lock(options={})
|
447
|
+
* @param [::Hash] options 利用可能なオプションは以下の通り。
|
448
|
+
* @option options :timeout
|
449
|
+
* ロックを獲得できなかった場合は _:timeout_ 秒間ロックの獲
|
450
|
+
* 得を試みる。 _:timeout_ 秒以内にロックを獲得できなかった
|
451
|
+
* 場合は例外が発生する。
|
452
|
+
* @overload lock(options={})
|
453
|
+
* @yield ブロックを指定した場合はブロックを抜けたときにunlockする。
|
454
|
+
* @param [::Hash] options 利用可能なオプションは以下の通り。
|
455
|
+
* @option options :timeout
|
456
|
+
* ロックを獲得できなかった場合は _:timeout_秒間ロックの獲
|
457
|
+
* 得を試みる。 _:timeout_秒以内にロックを獲得できなかった
|
458
|
+
* 場合は例外が発生する。
|
443
459
|
*/
|
444
460
|
static VALUE
|
445
461
|
rb_grn_database_lock (int argc, VALUE *argv, VALUE self)
|
@@ -537,18 +553,14 @@ rb_grn_database_touch (VALUE self)
|
|
537
553
|
}
|
538
554
|
|
539
555
|
/*
|
540
|
-
* Document-method: defrag
|
541
|
-
*
|
542
|
-
* call-seq:
|
543
|
-
* database.defrag(options={}) -> n_segments
|
544
|
-
*
|
545
556
|
* Defrags all variable size columns in the database.
|
546
|
-
*
|
547
557
|
* @return [Integer] the number of defraged segments
|
548
|
-
* @
|
549
|
-
*
|
550
|
-
*
|
551
|
-
*
|
558
|
+
* @overload defrag(options={})
|
559
|
+
* @param [::Hash] options option for defrag
|
560
|
+
* @option options [Integer] :threshold (0) the threshold to
|
561
|
+
* determine whether a segment is defraged. Available
|
562
|
+
* values are -4..22. -4 means all segments are defraged.
|
563
|
+
* 22 means no segment is defraged.
|
552
564
|
* @since 1.2.6
|
553
565
|
*/
|
554
566
|
static VALUE
|
@@ -43,91 +43,9 @@ VALUE rb_cGrnDoubleArrayTrie;
|
|
43
43
|
*/
|
44
44
|
|
45
45
|
/*
|
46
|
-
* call-seq:
|
47
|
-
* Groonga::DoubleArrayTrie.create(options={}) -> Groonga::DoubleArrayTrie
|
48
|
-
* Groonga::DoubleArrayTrie.create(options={}) {|table| ... }
|
49
|
-
*
|
50
46
|
* It creates a table that manages records by double array trie.
|
51
47
|
* ブロックを指定すると、そのブロックに生成したテーブルが渡さ
|
52
48
|
* れ、ブロックを抜けると自動的にテーブルが破棄される。
|
53
|
-
*
|
54
|
-
* _options_ に指定可能な値は以下の通り。
|
55
|
-
* @param options [::Hash] The name and value
|
56
|
-
* pairs. Omitted names are initialized as the default value.
|
57
|
-
* @option options [Groonga::Context] :context (Groonga::Context.default)
|
58
|
-
*
|
59
|
-
* テーブルが利用するGroonga::Context。
|
60
|
-
*
|
61
|
-
* @option options :name The table name
|
62
|
-
*
|
63
|
-
* テーブルの名前。名前をつけると、Groonga::Context#[]に名
|
64
|
-
* 前を指定してテーブルを取得することができる。省略すると
|
65
|
-
* 無名テーブルになり、テーブルIDでのみ取得できる。
|
66
|
-
*
|
67
|
-
* @option options :path The path
|
68
|
-
*
|
69
|
-
* テーブルを保存するパス。パスを指定すると永続テーブルとな
|
70
|
-
* り、プロセス終了後もレコードは保持される。次回起動時に
|
71
|
-
* Groonga::Context#[]で保存されたレコードを利用する
|
72
|
-
* ことができる。省略すると一時テーブルになり、プロセスが終
|
73
|
-
* 了するとレコードは破棄される。
|
74
|
-
*
|
75
|
-
* @option options :persistent The persistent
|
76
|
-
*
|
77
|
-
* +true+ を指定すると永続テーブルとなる。 +path+ を省略した
|
78
|
-
* 場合は自動的にパスが付加される。 +:context+ で指定した
|
79
|
-
* Groonga::Contextに結びついているデータベースが一時デー
|
80
|
-
* タベースの場合は例外が発生する。
|
81
|
-
*
|
82
|
-
* @option options :key_normalize The key_normalize
|
83
|
-
*
|
84
|
-
* +true+ を指定するとキーを正規化する。
|
85
|
-
*
|
86
|
-
* @option options :key_with_sis The key_with_sis
|
87
|
-
*
|
88
|
-
* +true+ を指定するとキーの文字列の全suffixが自動的に登
|
89
|
-
* 録される。
|
90
|
-
*
|
91
|
-
* @option options :key_type The key_type
|
92
|
-
*
|
93
|
-
* キーの種類を示すオブジェクトを指定する。キーの種類には型
|
94
|
-
* 名("Int32"や"ShortText"など)またはGroonga::Typeまたは
|
95
|
-
* テーブル(Groonga::Array、Groonga::Hash、
|
96
|
-
* Groonga::DoubleArrayTrieのどれか)を指定する。
|
97
|
-
*
|
98
|
-
* Groonga::Typeを指定した場合は、その型が示す範囲の値をキー
|
99
|
-
* として使用する。ただし、キーの最大サイズは4096バイトで
|
100
|
-
* あるため、Groonga::Type::TEXTやGroonga::Type::LONG_TEXT
|
101
|
-
* は使用できない。
|
102
|
-
*
|
103
|
-
* テーブルを指定した場合はレコードIDをキーとして使用する。
|
104
|
-
* 指定したテーブルのGroonga::Recordをキーとして使用するこ
|
105
|
-
* ともでき、その場合は自動的にGroonga::Recordからレコード
|
106
|
-
* IDを取得する。
|
107
|
-
*
|
108
|
-
* 省略した場合はShortText型をキーとして使用する。この場合、
|
109
|
-
* 4096バイトまで使用可能である。
|
110
|
-
*
|
111
|
-
* @option options :value_type The value_type
|
112
|
-
*
|
113
|
-
* 値の型を指定する。省略すると値のための領域を確保しない。
|
114
|
-
* 値を保存したい場合は必ず指定すること。
|
115
|
-
*
|
116
|
-
* 参考: Groonga::Type.new
|
117
|
-
*
|
118
|
-
* @option options :default_tokenizer The default_tokenizer
|
119
|
-
*
|
120
|
-
* Groonga::IndexColumnで使用するトークナイザを指定する。
|
121
|
-
* デフォルトでは何も設定されていないので、テーブルに
|
122
|
-
* Groonga::IndexColumnを定義する場合は
|
123
|
-
* <tt>"TokenBigram"</tt>などを指定する必要がある。
|
124
|
-
*
|
125
|
-
* @option options :sub_records The sub_records
|
126
|
-
*
|
127
|
-
* +true+ を指定すると#groupでグループ化したときに、
|
128
|
-
* Groonga::Record#n_sub_recordsでグループに含まれるレコー
|
129
|
-
* ドの件数を取得できる。
|
130
|
-
*
|
131
49
|
* @example
|
132
50
|
* #無名一時テーブルを生成する。
|
133
51
|
* Groonga::DoubleArrayTrie.create
|
@@ -138,7 +56,7 @@ VALUE rb_cGrnDoubleArrayTrie;
|
|
138
56
|
* #名前付き永続テーブルを生成する。ただし、ファイル名は気に
|
139
57
|
* #しない。
|
140
58
|
* Groonga::DoubleArrayTrie.create(:name => "Bookmarks",
|
141
|
-
*
|
59
|
+
* :persistent => true)
|
142
60
|
*
|
143
61
|
* #それぞれのレコードに512バイトの値を格納できる無名一時テー
|
144
62
|
* #ブルを生成する。
|
@@ -167,9 +85,127 @@ VALUE rb_cGrnDoubleArrayTrie;
|
|
167
85
|
* bookmarks = Groonga::DoubleArrayTrie.create(:name => "Bookmarks")
|
168
86
|
* bookmarks.define_column("comment", "Text")
|
169
87
|
* terms = Groonga::DoubleArrayTrie.create(:name => "Terms",
|
170
|
-
*
|
88
|
+
* :default_tokenizer => "TokenBigram")
|
171
89
|
* terms.define_index_column("content", bookmarks,
|
172
90
|
* :source => "Bookmarks.comment")
|
91
|
+
*
|
92
|
+
* @overload create(options={})
|
93
|
+
* @return [Groonga::DoubleArrayTrie]
|
94
|
+
* @param [::Hash] options The name and value
|
95
|
+
* pairs. Omitted names are initialized as the default value.
|
96
|
+
* @option options [Groonga::Context] :context (Groonga::Context.default)
|
97
|
+
* テーブルが利用するGroonga::Context。
|
98
|
+
* @option options :name
|
99
|
+
* テーブルの名前。名前をつけると、Groonga::Context#[]に名
|
100
|
+
* 前を指定してテーブルを取得することができる。省略すると
|
101
|
+
* 無名テーブルになり、テーブルIDでのみ取得できる。
|
102
|
+
* @option options :path
|
103
|
+
* テーブルを保存するパス。パスを指定すると永続テーブルとな
|
104
|
+
* り、プロセス終了後もレコードは保持される。次回起動時に
|
105
|
+
* Groonga::Context#[]で保存されたレコードを利用する
|
106
|
+
* ことができる。省略すると一時テーブルになり、プロセスが終
|
107
|
+
* 了するとレコードは破棄される。
|
108
|
+
* @option options :persistent
|
109
|
+
* +true+ を指定すると永続テーブルとなる。 +path+ を省略した
|
110
|
+
* 場合は自動的にパスが付加される。 +:context+ で指定した
|
111
|
+
* Groonga::Contextに結びついているデータベースが一時デー
|
112
|
+
* タベースの場合は例外が発生する。
|
113
|
+
* @option options :key_normalize
|
114
|
+
* +true+ を指定するとキーを正規化する。
|
115
|
+
* @option options :key_with_sis
|
116
|
+
* +true+ を指定するとキーの文字列の全suffixが自動的に登
|
117
|
+
* 録される。
|
118
|
+
* @option options :key_type
|
119
|
+
* キーの種類を示すオブジェクトを指定する。キーの種類には型
|
120
|
+
* 名("Int32"や"ShortText"など)またはGroonga::Typeまたは
|
121
|
+
* テーブル(Groonga::Array、Groonga::Hash、
|
122
|
+
* Groonga::DoubleArrayTrieのどれか)を指定する。
|
123
|
+
* Groonga::Typeを指定した場合は、その型が示す範囲の値をキー
|
124
|
+
* として使用する。ただし、キーの最大サイズは4096バイトで
|
125
|
+
* あるため、Groonga::Type::TEXTやGroonga::Type::LONG_TEXT
|
126
|
+
* は使用できない。
|
127
|
+
*
|
128
|
+
* テーブルを指定した場合はレコードIDをキーとして使用する。
|
129
|
+
* 指定したテーブルのGroonga::Recordをキーとして使用するこ
|
130
|
+
* ともでき、その場合は自動的にGroonga::Recordからレコード
|
131
|
+
* IDを取得する。
|
132
|
+
*
|
133
|
+
* 省略した場合はShortText型をキーとして使用する。この場合、
|
134
|
+
* 4096バイトまで使用可能である。
|
135
|
+
* @option options :value_type
|
136
|
+
* 値の型を指定する。省略すると値のための領域を確保しない。
|
137
|
+
* 値を保存したい場合は必ず指定すること。
|
138
|
+
*
|
139
|
+
* 参考: Groonga::Type.new
|
140
|
+
*
|
141
|
+
* @option options :default_tokenizer
|
142
|
+
* Groonga::IndexColumnで使用するトークナイザを指定する。
|
143
|
+
* デフォルトでは何も設定されていないので、テーブルに
|
144
|
+
* Groonga::IndexColumnを定義する場合は
|
145
|
+
* <tt>"TokenBigram"</tt>などを指定する必要がある。
|
146
|
+
* @option options :sub_records
|
147
|
+
* +true+ を指定すると#groupでグループ化したときに、
|
148
|
+
* Groonga::Record#n_sub_recordsでグループに含まれるレコー
|
149
|
+
* ドの件数を取得できる。
|
150
|
+
* @overload create(options={})
|
151
|
+
* @yield [table]
|
152
|
+
* @param [::Hash] options The name and value
|
153
|
+
* pairs. Omitted names are initialized as the default value.
|
154
|
+
* @option options [Groonga::Context] :context (Groonga::Context.default)
|
155
|
+
* テーブルが利用するGroonga::Context。
|
156
|
+
* @option options :name
|
157
|
+
* テーブルの名前。名前をつけると、Groonga::Context#[]に名
|
158
|
+
* 前を指定してテーブルを取得することができる。省略すると
|
159
|
+
* 無名テーブルになり、テーブルIDでのみ取得できる。
|
160
|
+
* @option options :path
|
161
|
+
* テーブルを保存するパス。パスを指定すると永続テーブルとな
|
162
|
+
* り、プロセス終了後もレコードは保持される。次回起動時に
|
163
|
+
* Groonga::Context#[]で保存されたレコードを利用する
|
164
|
+
* ことができる。省略すると一時テーブルになり、プロセスが終
|
165
|
+
* 了するとレコードは破棄される。
|
166
|
+
* @option options :persistent
|
167
|
+
* +true+ を指定すると永続テーブルとなる。 +path+ を省略した
|
168
|
+
* 場合は自動的にパスが付加される。 +:context+ で指定した
|
169
|
+
* Groonga::Contextに結びついているデータベースが一時デー
|
170
|
+
* タベースの場合は例外が発生する。
|
171
|
+
* @option options :key_normalize
|
172
|
+
* +true+ を指定するとキーを正規化する。
|
173
|
+
* @option options :key_with_sis
|
174
|
+
* +true+ を指定するとキーの文字列の全suffixが自動的に登
|
175
|
+
* 録される。
|
176
|
+
* @option options :key_type
|
177
|
+
* キーの種類を示すオブジェクトを指定する。キーの種類には型
|
178
|
+
* 名("Int32"や"ShortText"など)またはGroonga::Typeまたは
|
179
|
+
* テーブル(Groonga::Array、Groonga::Hash、
|
180
|
+
* Groonga::DoubleArrayTrieのどれか)を指定する。
|
181
|
+
* Groonga::Typeを指定した場合は、その型が示す範囲の値をキー
|
182
|
+
* として使用する。ただし、キーの最大サイズは4096バイトで
|
183
|
+
* あるため、Groonga::Type::TEXTやGroonga::Type::LONG_TEXT
|
184
|
+
* は使用できない。
|
185
|
+
*
|
186
|
+
* テーブルを指定した場合はレコードIDをキーとして使用する。
|
187
|
+
* 指定したテーブルのGroonga::Recordをキーとして使用するこ
|
188
|
+
* ともでき、その場合は自動的にGroonga::Recordからレコード
|
189
|
+
* IDを取得する。
|
190
|
+
*
|
191
|
+
* 省略した場合はShortText型をキーとして使用する。この場合、
|
192
|
+
* 4096バイトまで使用可能である。
|
193
|
+
* @option options :value_type
|
194
|
+
* 値の型を指定する。省略すると値のための領域を確保しない。
|
195
|
+
* 値を保存したい場合は必ず指定すること。
|
196
|
+
*
|
197
|
+
* 参考: Groonga::Type.new
|
198
|
+
*
|
199
|
+
* @option options :default_tokenizer
|
200
|
+
* Groonga::IndexColumnで使用するトークナイザを指定する。
|
201
|
+
* デフォルトでは何も設定されていないので、テーブルに
|
202
|
+
* Groonga::IndexColumnを定義する場合は
|
203
|
+
* <tt>"TokenBigram"</tt>などを指定する必要がある。
|
204
|
+
* @option options :sub_records
|
205
|
+
* +true+ を指定すると#groupでグループ化したときに、
|
206
|
+
* Groonga::Record#n_sub_recordsでグループに含まれるレコー
|
207
|
+
* ドの件数を取得できる。
|
208
|
+
*
|
173
209
|
*/
|
174
210
|
static VALUE
|
175
211
|
rb_grn_double_array_trie_s_create (int argc, VALUE *argv, VALUE klass)
|
@@ -251,43 +287,13 @@ rb_grn_double_array_trie_s_create (int argc, VALUE *argv, VALUE klass)
|
|
251
287
|
}
|
252
288
|
|
253
289
|
/*
|
254
|
-
* call-seq:
|
255
|
-
* double_array_trie.search(key, options=nil) -> Groonga::Hash
|
256
|
-
*
|
257
290
|
* _key_ にマッチするレコードのIDがキーに入っている
|
258
291
|
* Groonga::Hashを返す。マッチするレコードがない場合は空の
|
259
292
|
* Groonga::Hashが返る。
|
260
|
-
*
|
261
293
|
* _options_ で +:result+ を指定することにより、そのテーブルにマッ
|
262
294
|
* チしたレコードIDがキーのレコードを追加することができる。
|
263
295
|
* +:result+ にテーブルを指定した場合は、そのテーブルが返る。
|
264
|
-
*
|
265
|
-
* _options_ に指定可能な値は以下の通り。
|
266
|
-
* @param options [::Hash] The name and value
|
267
|
-
* pairs. Omitted names are initialized as the default value.
|
268
|
-
* @option options :result The result
|
269
|
-
*
|
270
|
-
* 結果を格納するテーブル。
|
271
|
-
* @option options :operator (Groonga::Operator::OR)
|
272
|
-
*
|
273
|
-
* マッチしたレコードをどのように扱うか。指定可能な値は以
|
274
|
-
* 下の通り。
|
275
|
-
*
|
276
|
-
* [Groonga::Operator::OR]
|
277
|
-
* マッチしたレコードを追加。すでにレコードが追加され
|
278
|
-
* ている場合は何もしない。
|
279
|
-
* [Groonga::Operator::AND]
|
280
|
-
* マッチしたレコードのスコアを増加。マッチしなかった
|
281
|
-
* レコードを削除。
|
282
|
-
* [Groonga::Operator::BUT]
|
283
|
-
* マッチしたレコードを削除。
|
284
|
-
* [Groonga::Operator::ADJUST]
|
285
|
-
* マッチしたレコードのスコアを増加。
|
286
|
-
*
|
287
|
-
* [+:type+]
|
288
|
-
* ?????
|
289
|
-
*
|
290
|
-
* 複数のキーで検索し、結果を1つのテーブルに集める。
|
296
|
+
* @example 複数のキーで検索し、結果を1つのテーブルに集める。
|
291
297
|
* result = nil
|
292
298
|
* keys = ["morita", "gunyara-kun", "yu"]
|
293
299
|
* keys.each do |key|
|
@@ -297,6 +303,30 @@ rb_grn_double_array_trie_s_create (int argc, VALUE *argv, VALUE klass)
|
|
297
303
|
* user = record.key
|
298
304
|
* p user.key # -> "morita"または"gunyara-kun"または"yu"
|
299
305
|
* end
|
306
|
+
*
|
307
|
+
* @overload search(key, options=nil)
|
308
|
+
* @return [Groonga::Hash]
|
309
|
+
* @param key [String] レコードにマッチさせる値
|
310
|
+
* @param options [::Hash] The name and value
|
311
|
+
* pairs. Omitted names are initialized as the default value.
|
312
|
+
* @option options :result The result
|
313
|
+
* 結果を格納するテーブル。
|
314
|
+
* @option options :operator (Groonga::Operator::OR)
|
315
|
+
* マッチしたレコードをどのように扱うか。指定可能な値は以
|
316
|
+
* 下の通り。
|
317
|
+
* [Groonga::Operator::OR]
|
318
|
+
* マッチしたレコードを追加。すでにレコードが追加され
|
319
|
+
* ている場合は何もしない。
|
320
|
+
* [Groonga::Operator::AND]
|
321
|
+
* マッチしたレコードのスコアを増加。マッチしなかった
|
322
|
+
* レコードを削除。
|
323
|
+
* [Groonga::Operator::BUT]
|
324
|
+
* マッチしたレコードを削除。
|
325
|
+
* [Groonga::Operator::ADJUST]
|
326
|
+
* マッチしたレコードのスコアを増加。
|
327
|
+
* [+:type+]
|
328
|
+
* ?????
|
329
|
+
*
|
300
330
|
*/
|
301
331
|
static VALUE
|
302
332
|
rb_grn_double_array_trie_search (int argc, VALUE *argv, VALUE self)
|
@@ -441,59 +471,71 @@ rb_grn_double_array_trie_open_grn_prefix_cursor (int argc, VALUE *argv,
|
|
441
471
|
return cursor;
|
442
472
|
}
|
443
473
|
|
444
|
-
|
445
474
|
/*
|
446
|
-
* call-seq:
|
447
|
-
* table.open_prefix_cursor(prefix, options={}) -> Groonga::DoubleArrayTrieCursor
|
448
|
-
* table.open_prefix_cursor(prefix, options={}) {|cursor| ... }
|
449
|
-
*
|
450
475
|
* _prefix_ に前方一致検索をするカーソルを生成して返す。ブロッ
|
451
476
|
* クを指定すると、そのブロックに生成したカーソルが渡され、ブ
|
452
477
|
* ロックを抜けると自動的にカーソルが破棄される。
|
453
478
|
*
|
454
|
-
*
|
455
|
-
*
|
456
|
-
*
|
457
|
-
*
|
458
|
-
*
|
459
|
-
*
|
460
|
-
*
|
461
|
-
*
|
462
|
-
*
|
463
|
-
*
|
464
|
-
*
|
465
|
-
*
|
466
|
-
*
|
467
|
-
*
|
468
|
-
*
|
469
|
-
*
|
470
|
-
*
|
471
|
-
*
|
472
|
-
*
|
473
|
-
*
|
474
|
-
*
|
475
|
-
*
|
476
|
-
*
|
477
|
-
*
|
478
|
-
*
|
479
|
-
*
|
480
|
-
*
|
481
|
-
*
|
482
|
-
*
|
483
|
-
*
|
484
|
-
*
|
485
|
-
*
|
486
|
-
*
|
487
|
-
*
|
488
|
-
*
|
489
|
-
*
|
490
|
-
*
|
491
|
-
*
|
492
|
-
*
|
493
|
-
*
|
494
|
-
*
|
495
|
-
*
|
496
|
-
*
|
479
|
+
* @overload open_prefix_cursor(prefix, options={})
|
480
|
+
* @return [Groonga::DoubleArrayTrieCursor]
|
481
|
+
* @param [String] prefix 前方一致させる値
|
482
|
+
* @param options [::Hash] The name and value
|
483
|
+
* pairs. Omitted names are initialized as the default value.
|
484
|
+
* @option options :key_bytes
|
485
|
+
* _prefix_ のサイズ(byte)
|
486
|
+
* @option options :key_bits
|
487
|
+
* _prefix_ のサイズ(bit)
|
488
|
+
* @option options :offset
|
489
|
+
* 該当する範囲のレコードのうち、(0ベースで) _:offset_ 番目
|
490
|
+
* からレコードを取り出す。
|
491
|
+
* @option options :limit
|
492
|
+
* 該当する範囲のレコードのうち、 _:limit_ 件のみを取り出す。
|
493
|
+
* 省略された場合または-1が指定された場合は、全件が指定され
|
494
|
+
* たものとみなす。
|
495
|
+
* @option options :order
|
496
|
+
* +:asc+ または +:ascending+ を指定すると昇順にレコードを取
|
497
|
+
* り出す。
|
498
|
+
* +:desc+ または +:descending+ を指定すると降順にレコードを
|
499
|
+
* 取り出す。
|
500
|
+
* @option options :order_by (:id)
|
501
|
+
* +:id+ を指定するとID順にレコードを取り出す。(デフォルト)
|
502
|
+
* +:key+指定するとキー順にレコードを取り出す。
|
503
|
+
* @option options :greater_than
|
504
|
+
* +true+ を指定すると _prefix_ で指定した値に一致した [ +key+ ] を
|
505
|
+
* 範囲に含まない。
|
506
|
+
* @option options :less_than
|
507
|
+
* +true+ を指定すると _prefix_ で指定した値に一致した [ +key+ ] を
|
508
|
+
* 範囲に含まない。
|
509
|
+
* @overload open_prefix_cursor(prefix, options={})
|
510
|
+
* @yield [cursor]
|
511
|
+
* @param [String] prefix 前方一致させる値
|
512
|
+
* @param options [::Hash] The name and value
|
513
|
+
* pairs. Omitted names are initialized as the default value.
|
514
|
+
* @option options :key_bytes
|
515
|
+
* _prefix_ のサイズ(byte)
|
516
|
+
* @option options :key_bits
|
517
|
+
* _prefix_ のサイズ(bit)
|
518
|
+
* @option options :offset
|
519
|
+
* 該当する範囲のレコードのうち、(0ベースで) _:offset_ 番目
|
520
|
+
* からレコードを取り出す。
|
521
|
+
* @option options :limit
|
522
|
+
* 該当する範囲のレコードのうち、 _:limit_ 件のみを取り出す。
|
523
|
+
* 省略された場合または-1が指定された場合は、全件が指定され
|
524
|
+
* たものとみなす。
|
525
|
+
* @option options :order
|
526
|
+
* +:asc+ または +:ascending+ を指定すると昇順にレコードを取
|
527
|
+
* り出す。
|
528
|
+
* +:desc+ または +:descending+ を指定すると降順にレコードを
|
529
|
+
* 取り出す。
|
530
|
+
* @option options :order_by (:id)
|
531
|
+
* +:id+ を指定するとID順にレコードを取り出す。(デフォルト)
|
532
|
+
* +:key+指定するとキー順にレコードを取り出す。
|
533
|
+
* @option options :greater_than
|
534
|
+
* +true+ を指定すると _prefix_ で指定した値に一致した [ +key+ ] を
|
535
|
+
* 範囲に含まない。
|
536
|
+
* @option options :less_than
|
537
|
+
* +true+ を指定すると _prefix_ で指定した値に一致した [ +key+ ] を
|
538
|
+
* 範囲に含まない。
|
497
539
|
*/
|
498
540
|
static VALUE
|
499
541
|
rb_grn_double_array_trie_open_prefix_cursor (int argc, VALUE *argv, VALUE self)
|