rroonga 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -1
- data/ext/groonga/extconf.rb +36 -4
- data/ext/groonga/rb-grn-accessor.c +8 -10
- data/ext/groonga/rb-grn-array-cursor.c +2 -2
- data/ext/groonga/rb-grn-array.c +35 -59
- data/ext/groonga/rb-grn-column.c +105 -192
- data/ext/groonga/rb-grn-context.c +60 -63
- data/ext/groonga/rb-grn-database.c +27 -37
- data/ext/groonga/rb-grn-double-array-trie-cursor.c +3 -3
- data/ext/groonga/rb-grn-double-array-trie.c +75 -126
- data/ext/groonga/rb-grn-encoding.c +27 -27
- data/ext/groonga/rb-grn-expression.c +29 -24
- data/ext/groonga/rb-grn-fix-size-column.c +7 -9
- data/ext/groonga/rb-grn-hash-cursor.c +3 -3
- data/ext/groonga/rb-grn-hash.c +57 -108
- data/ext/groonga/rb-grn-index-column.c +17 -29
- data/ext/groonga/rb-grn-logger.c +11 -14
- data/ext/groonga/rb-grn-object.c +51 -94
- data/ext/groonga/rb-grn-patricia-trie-cursor.c +2 -2
- data/ext/groonga/rb-grn-patricia-trie.c +161 -276
- data/ext/groonga/rb-grn-plugin.c +6 -10
- data/ext/groonga/rb-grn-table-cursor.c +14 -21
- data/ext/groonga/rb-grn-table-key-support.c +32 -35
- data/ext/groonga/rb-grn-table.c +149 -252
- data/ext/groonga/rb-grn-variable.c +6 -7
- data/ext/groonga/rb-grn-view-accessor.c +1 -1
- data/ext/groonga/rb-grn-view-cursor.c +2 -2
- data/ext/groonga/rb-grn-view.c +28 -45
- data/ext/groonga/rb-grn.h +1 -1
- data/ext/groonga/rb-groonga.c +6 -6
- data/lib/groonga/database.rb +1 -1
- data/lib/groonga/dumper.rb +109 -33
- data/lib/groonga/expression-builder.rb +24 -0
- data/lib/groonga/pagination.rb +30 -24
- data/lib/groonga/record.rb +21 -18
- data/lib/groonga/schema.rb +156 -140
- data/test/test-command-select.rb +66 -1
- data/test/test-database-dumper.rb +50 -10
- data/test/test-expression-builder.rb +41 -0
- metadata +4 -4
@@ -30,15 +30,17 @@ static VALUE cGrnContext;
|
|
30
30
|
* 複数のコンテキストを利用する必要はない。
|
31
31
|
*
|
32
32
|
* デフォルトで使用されるコンテキストは
|
33
|
-
* Groonga::Context
|
34
|
-
*
|
35
|
-
*
|
33
|
+
* {Groonga::Context.default} でアクセスできる。コンテキ
|
34
|
+
* ストを指定できる箇所でコンテキストの指定を省略したり +nil+
|
35
|
+
* を指定した場合は {Groonga::Context.default} が利用さ
|
36
|
+
* れる。
|
36
37
|
*
|
37
38
|
* また、デフォルトのコンテキストは必要になると暗黙のうちに
|
38
39
|
* 作成される。そのため、コンテキストを意識することは少ない。
|
39
40
|
*
|
40
41
|
* 暗黙のうちに作成されるコンテキストにオプションを指定する
|
41
|
-
* 場合はGroonga::Context.default_options
|
42
|
+
* 場合は {Groonga::Context.default_options=} を使用
|
43
|
+
* する。
|
42
44
|
*/
|
43
45
|
|
44
46
|
grn_ctx *
|
@@ -325,15 +327,15 @@ rb_grn_context_text_set (grn_ctx *context, grn_obj *bulk, VALUE rb_string)
|
|
325
327
|
}
|
326
328
|
|
327
329
|
/*
|
328
|
-
* call-seq:
|
329
|
-
* Groonga::Context.default -> Groonga::Context
|
330
|
-
*
|
331
330
|
* デフォルトのコンテキストを返す。デフォルトのコンテキスト
|
332
331
|
* が作成されていない場合は暗黙のうちに作成し、それを返す。
|
333
332
|
*
|
334
333
|
* 暗黙のうちにコンテキストを作成する場合は、
|
335
|
-
* Groonga::Context.default_options
|
336
|
-
*
|
334
|
+
* {Groonga::Context.default_options} に設定されているオプ
|
335
|
+
* ションを利用する。
|
336
|
+
*
|
337
|
+
* @overload default
|
338
|
+
* @return [Groonga::Context]
|
337
339
|
*/
|
338
340
|
static VALUE
|
339
341
|
rb_grn_context_s_get_default (VALUE self)
|
@@ -355,13 +357,12 @@ rb_grn_context_get_default (void)
|
|
355
357
|
}
|
356
358
|
|
357
359
|
/*
|
358
|
-
* call-seq:
|
359
|
-
* Groonga::Context.default=(context)
|
360
|
-
*
|
361
360
|
* デフォルトのコンテキストを設定する。 +nil+ を指定すると、
|
362
361
|
* デフォルトのコンテキストをリセットする。リセットすると、次
|
363
|
-
* 回Groonga::Context.default
|
364
|
-
*
|
362
|
+
* 回 {Groonga::Context.default} を呼び出したときに新しくコ
|
363
|
+
* ンテキストが作成される。
|
364
|
+
*
|
365
|
+
* @overload default=(context)
|
365
366
|
*/
|
366
367
|
static VALUE
|
367
368
|
rb_grn_context_s_set_default (VALUE self, VALUE context)
|
@@ -371,11 +372,11 @@ rb_grn_context_s_set_default (VALUE self, VALUE context)
|
|
371
372
|
}
|
372
373
|
|
373
374
|
/*
|
374
|
-
* call-seq:
|
375
|
-
* Groonga::Context.default_options -> Hash or nil
|
376
|
-
*
|
377
375
|
* コンテキストを作成する時に利用するデフォルトのオプション
|
378
376
|
* を返す。
|
377
|
+
*
|
378
|
+
* @overload default_options
|
379
|
+
* @return [::Hash or nil]
|
379
380
|
*/
|
380
381
|
static VALUE
|
381
382
|
rb_grn_context_s_get_default_options (VALUE self)
|
@@ -384,12 +385,11 @@ rb_grn_context_s_get_default_options (VALUE self)
|
|
384
385
|
}
|
385
386
|
|
386
387
|
/*
|
387
|
-
* call-seq:
|
388
|
-
* Groonga::Context.default_options=(options)
|
389
|
-
*
|
390
388
|
* コンテキストを作成する時に利用するデフォルトのオプション
|
391
389
|
* を設定する。利用可能なオプションは
|
392
|
-
* Groonga::Context.newを参照。
|
390
|
+
* {Groonga::Context.new} を参照。
|
391
|
+
*
|
392
|
+
* @overload default_options=(options)
|
393
393
|
*/
|
394
394
|
static VALUE
|
395
395
|
rb_grn_context_s_set_default_options (VALUE self, VALUE options)
|
@@ -405,7 +405,7 @@ rb_grn_context_s_set_default_options (VALUE self, VALUE options)
|
|
405
405
|
* pairs. Omitted names are initialized as the default value.
|
406
406
|
* @option options [Groonga::Encoding] :encoding The encoding
|
407
407
|
* エンコーディングを指定する。エンコーディングの指定方法
|
408
|
-
* はGroonga::Encodingを参照。
|
408
|
+
* は {Groonga::Encoding} を参照。
|
409
409
|
*/
|
410
410
|
static VALUE
|
411
411
|
rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
|
@@ -454,11 +454,10 @@ rb_grn_context_initialize (int argc, VALUE *argv, VALUE self)
|
|
454
454
|
}
|
455
455
|
|
456
456
|
/*
|
457
|
-
* call-seq:
|
458
|
-
* context.close
|
459
|
-
*
|
460
457
|
* Closes the _context_. Closed _context_ can't be used
|
461
458
|
* anymore.
|
459
|
+
*
|
460
|
+
* @overload close
|
462
461
|
*/
|
463
462
|
static VALUE
|
464
463
|
rb_grn_context_close (VALUE self)
|
@@ -479,10 +478,9 @@ rb_grn_context_close (VALUE self)
|
|
479
478
|
}
|
480
479
|
|
481
480
|
/*
|
482
|
-
* call-seq:
|
483
|
-
* context.closed?
|
484
|
-
*
|
485
481
|
* Returns whether the _context_ is closed by #close or not.
|
482
|
+
*
|
483
|
+
* @overload closed?
|
486
484
|
*/
|
487
485
|
static VALUE
|
488
486
|
rb_grn_context_closed_p (VALUE self)
|
@@ -495,10 +493,10 @@ rb_grn_context_closed_p (VALUE self)
|
|
495
493
|
}
|
496
494
|
|
497
495
|
/*
|
498
|
-
* call-seq:
|
499
|
-
* context.inspect -> String
|
500
|
-
*
|
501
496
|
* コンテキストの中身を人に見やすい文字列で返す。
|
497
|
+
*
|
498
|
+
* @overload inspect
|
499
|
+
* @return [String]
|
502
500
|
*/
|
503
501
|
static VALUE
|
504
502
|
rb_grn_context_inspect (VALUE self)
|
@@ -535,10 +533,10 @@ rb_grn_context_inspect (VALUE self)
|
|
535
533
|
}
|
536
534
|
|
537
535
|
/*
|
538
|
-
* call-seq:
|
539
|
-
* context.encoding -> Groonga::Encoding
|
540
|
-
*
|
541
536
|
* コンテキストが使うエンコーディングを返す。
|
537
|
+
*
|
538
|
+
* @overload encoding
|
539
|
+
* @return [Groonga::Encoding]
|
542
540
|
*/
|
543
541
|
static VALUE
|
544
542
|
rb_grn_context_get_encoding (VALUE self)
|
@@ -547,11 +545,10 @@ rb_grn_context_get_encoding (VALUE self)
|
|
547
545
|
}
|
548
546
|
|
549
547
|
/*
|
550
|
-
* call-seq:
|
551
|
-
* context.encoding=(encoding)
|
552
|
-
*
|
553
548
|
* コンテキストが使うエンコーディングを設定する。エンコーディ
|
554
|
-
* ングの指定のしかたはGroonga::Encodingを参照。
|
549
|
+
* ングの指定のしかたは {Groonga::Encoding} を参照。
|
550
|
+
*
|
551
|
+
* @overload encoding=(encoding)
|
555
552
|
*/
|
556
553
|
static VALUE
|
557
554
|
rb_grn_context_set_encoding (VALUE self, VALUE rb_encoding)
|
@@ -589,13 +586,14 @@ rb_grn_context_get_ruby_encoding (VALUE self)
|
|
589
586
|
}
|
590
587
|
|
591
588
|
/*
|
592
|
-
* call-seq:
|
593
|
-
* context.match_escalation_threshold -> Integer
|
594
|
-
*
|
595
589
|
* このコンテキストを使って検索したときに検索の挙動をエスカレー
|
596
|
-
*
|
597
|
-
*
|
598
|
-
* http://groonga.org/docs/spec/search.html#
|
590
|
+
* ションする閾値を返します。
|
591
|
+
* エスカレーションの詳細は
|
592
|
+
* "groongaの検索の仕様に関するドキュメント":http://groonga.org/docs/spec/search.html#match-escalation-threshold
|
593
|
+
* を参照してください。
|
594
|
+
*
|
595
|
+
* @overload match_escalation_threshold
|
596
|
+
* @return [Integer]
|
599
597
|
*/
|
600
598
|
static VALUE
|
601
599
|
rb_grn_context_get_match_escalation_threshold (VALUE self)
|
@@ -604,13 +602,13 @@ rb_grn_context_get_match_escalation_threshold (VALUE self)
|
|
604
602
|
}
|
605
603
|
|
606
604
|
/*
|
607
|
-
* call-seq:
|
608
|
-
* context.match_escalation_threshold=(match_escalation_threshold)
|
609
|
-
*
|
610
605
|
* このコンテキストを使って検索したときに検索の挙動をエスカレー
|
611
|
-
*
|
612
|
-
*
|
613
|
-
* http://groonga.org/docs/spec/search.html#
|
606
|
+
* ションする閾値を設定します。
|
607
|
+
* エスカレーションの詳細は
|
608
|
+
* "groongaの検索の仕様に関するドキュメント":http://groonga.org/docs/spec/search.html#match-escalation-threshold
|
609
|
+
* を参照してください。
|
610
|
+
*
|
611
|
+
* @overload match_escalation_threshold=(match_escalation_threshold)
|
614
612
|
*/
|
615
613
|
static VALUE
|
616
614
|
rb_grn_context_set_match_escalation_threshold (VALUE self, VALUE threshold)
|
@@ -624,11 +622,10 @@ rb_grn_context_set_match_escalation_threshold (VALUE self, VALUE threshold)
|
|
624
622
|
}
|
625
623
|
|
626
624
|
/*
|
627
|
-
* call-seq:
|
628
|
-
* context.support_zlib?
|
629
|
-
*
|
630
625
|
* groongaがZlibサポート付きでビルドされていれば +true+ 、そう
|
631
626
|
* でなければ +false+ を返す。
|
627
|
+
*
|
628
|
+
* @overload support_zlib?
|
632
629
|
*/
|
633
630
|
static VALUE
|
634
631
|
rb_grn_context_support_zlib_p (VALUE self)
|
@@ -647,11 +644,10 @@ rb_grn_context_support_zlib_p (VALUE self)
|
|
647
644
|
}
|
648
645
|
|
649
646
|
/*
|
650
|
-
* call-seq:
|
651
|
-
* context.support_lzo?
|
652
|
-
*
|
653
647
|
* groongaがLZOサポート付きでビルドされていれば +true+ 、そう
|
654
648
|
* でなければ +false+ を返す。
|
649
|
+
*
|
650
|
+
* @overload support_lzo?
|
655
651
|
*/
|
656
652
|
static VALUE
|
657
653
|
rb_grn_context_support_lzo_p (VALUE self)
|
@@ -670,10 +666,10 @@ rb_grn_context_support_lzo_p (VALUE self)
|
|
670
666
|
}
|
671
667
|
|
672
668
|
/*
|
673
|
-
* call-seq:
|
674
|
-
* context.database -> Groonga::Database
|
675
|
-
*
|
676
669
|
* コンテキストが使うデータベースを返す。
|
670
|
+
*
|
671
|
+
* @overload database
|
672
|
+
* @return [Groonga::Database]
|
677
673
|
*/
|
678
674
|
static VALUE
|
679
675
|
rb_grn_context_get_database (VALUE self)
|
@@ -855,10 +851,6 @@ rb_grn_context_get_backward_compatibility (grn_ctx *context,
|
|
855
851
|
|
856
852
|
|
857
853
|
/*
|
858
|
-
* call-seq:
|
859
|
-
* context[name] -> Groonga::Object or nil
|
860
|
-
* context[id] -> Groonga::Object or nil
|
861
|
-
*
|
862
854
|
* コンテキスト管理下にあるオブジェクトを返す。
|
863
855
|
*
|
864
856
|
* _name_ として文字列を指定した場合はオブジェクト名でオブジェ
|
@@ -866,6 +858,11 @@ rb_grn_context_get_backward_compatibility (grn_ctx *context,
|
|
866
858
|
*
|
867
859
|
* _id_ として数値を指定した場合はオブジェクトIDでオブジェク
|
868
860
|
* トを検索する。
|
861
|
+
*
|
862
|
+
* @overload [](name)
|
863
|
+
* @return [Groonga::Object or nil]
|
864
|
+
* @overload [](id)
|
865
|
+
* @return [Groonga::Object or nil]
|
869
866
|
*/
|
870
867
|
static VALUE
|
871
868
|
rb_grn_context_array_reference (VALUE self, VALUE name_or_id)
|
@@ -135,13 +135,10 @@ rb_grn_database_finalizer (grn_ctx *context,
|
|
135
135
|
}
|
136
136
|
|
137
137
|
/*
|
138
|
-
* Document-method: close
|
139
|
-
*
|
140
|
-
* call-seq:
|
141
|
-
* database.close
|
142
|
-
*
|
143
138
|
* _database_ が使用しているリソースを開放する。これ以降 _database_ を
|
144
139
|
* 使うことはできない。
|
140
|
+
*
|
141
|
+
* @overload close
|
145
142
|
*/
|
146
143
|
static VALUE
|
147
144
|
rb_grn_database_close (VALUE self)
|
@@ -166,8 +163,16 @@ reset_floating_objects (VALUE rb_context)
|
|
166
163
|
/*
|
167
164
|
* 新しくデータベースを作成する。
|
168
165
|
* _options_ にはハッシュでオプションを指定する。
|
169
|
-
*
|
166
|
+
*
|
167
|
+
* @example
|
168
|
+
* # 一時データベースを作成:
|
169
|
+
* Groonga::Database.create
|
170
|
+
*
|
171
|
+
* # 永続データベースを作成:
|
172
|
+
* Groonga::Database.create(:path => "/tmp/db.groonga")
|
173
|
+
*
|
170
174
|
* @overload create(options=nil)
|
175
|
+
* @return [Groonga::Database] 作成されたデータベースを返す。
|
171
176
|
* @param option [::Hash] options The name and value
|
172
177
|
* pairs. Omitted names are initialized as the default value.
|
173
178
|
* @option options :path
|
@@ -175,14 +180,7 @@ reset_floating_objects (VALUE rb_context)
|
|
175
180
|
* となる。
|
176
181
|
* @option options :context (Groonga::Context.default)
|
177
182
|
* データベースを結びつけるコンテキスト。省略すると
|
178
|
-
* Groonga::Context.defaultを利用する。
|
179
|
-
*
|
180
|
-
* @example
|
181
|
-
* # 一時データベースを作成:
|
182
|
-
* Groonga::Database.create
|
183
|
-
*
|
184
|
-
* # 永続データベースを作成:
|
185
|
-
* Groonga::Database.create(:path => "/tmp/db.groonga")
|
183
|
+
* {Groonga::Context.default} を利用する。
|
186
184
|
*/
|
187
185
|
static VALUE
|
188
186
|
rb_grn_database_s_create (int argc, VALUE *argv, VALUE klass)
|
@@ -234,19 +232,20 @@ rb_grn_database_s_create (int argc, VALUE *argv, VALUE klass)
|
|
234
232
|
* 既存のデータベースを開く。ブロックを指定した場合はブロッ
|
235
233
|
* クに開いたデータベースを渡し、ブロックを抜けるときに閉じ
|
236
234
|
* る。
|
235
|
+
*
|
237
236
|
* @overload new(path, options=nil)
|
238
237
|
* @param options [::Hash] The name and value
|
239
238
|
* pairs. Omitted names are initialized as the default value.
|
240
239
|
* @option options :context (Groonga::Context.default)
|
241
240
|
* データベースを結びつけるコンテキスト。省略すると
|
242
|
-
* Groonga::Context.defaultを利用する。
|
241
|
+
* {Groonga::Context.default} を利用する。
|
243
242
|
* @return [Groonga::Database]
|
244
243
|
* @overload new(path, options=nil)
|
245
244
|
* @param options [::Hash] The name and value
|
246
245
|
* pairs. Omitted names are initialized as the default value.
|
247
246
|
* @option options :context (Groonga::Context.default)
|
248
247
|
* データベースを結びつけるコンテキスト。省略すると
|
249
|
-
* Groonga::Context.defaultを利用する。
|
248
|
+
* {Groonga::Context.default} を利用する。
|
250
249
|
* @yield [database]
|
251
250
|
* @yieldparam [Groonga::Database] database 開いたデータベース
|
252
251
|
*/
|
@@ -286,6 +285,7 @@ rb_grn_database_initialize (int argc, VALUE *argv, VALUE self)
|
|
286
285
|
* 既存のデータベースを開く。ブロックを指定した場合はブロッ
|
287
286
|
* クに開いたデータベースを渡し、ブロックを抜けるときに閉じ
|
288
287
|
* る。 _options_ にはハッシュでオプションを指定する。
|
288
|
+
*
|
289
289
|
* @overload open(path, options=nil)
|
290
290
|
* @return [Groonga::Database]
|
291
291
|
* @param options [::Hash] The name and value
|
@@ -315,6 +315,7 @@ rb_grn_database_s_open (int argc, VALUE *argv, VALUE klass)
|
|
315
315
|
|
316
316
|
/*
|
317
317
|
* データベース内のオブジェクトを順番にブロックに渡す。
|
318
|
+
*
|
318
319
|
* @example すべてのオブジェクトの名前を表示する:
|
319
320
|
* database.each do |object|
|
320
321
|
* p object.name
|
@@ -415,12 +416,9 @@ rb_grn_database_each (int argc, VALUE *argv, VALUE self)
|
|
415
416
|
}
|
416
417
|
|
417
418
|
/*
|
418
|
-
* Document-method: unlock
|
419
|
-
*
|
420
|
-
* call-seq:
|
421
|
-
* database.unlock
|
422
|
-
*
|
423
419
|
* _database_ のロックを解除する。
|
420
|
+
*
|
421
|
+
* @overload unlock
|
424
422
|
*/
|
425
423
|
static VALUE
|
426
424
|
rb_grn_database_unlock (VALUE self)
|
@@ -441,7 +439,7 @@ rb_grn_database_unlock (VALUE self)
|
|
441
439
|
|
442
440
|
/*
|
443
441
|
* _database_ をロックする。ロックに失敗した場合は
|
444
|
-
* Groonga::ResourceDeadlockAvoided例外が発生する。
|
442
|
+
* {Groonga::ResourceDeadlockAvoided} 例外が発生する。
|
445
443
|
*
|
446
444
|
* @overload lock(options={})
|
447
445
|
* @param [::Hash] options 利用可能なオプションは以下の通り。
|
@@ -490,12 +488,9 @@ rb_grn_database_lock (int argc, VALUE *argv, VALUE self)
|
|
490
488
|
}
|
491
489
|
|
492
490
|
/*
|
493
|
-
* Document-method: clear_lock
|
494
|
-
*
|
495
|
-
* call-seq:
|
496
|
-
* database.clear_lock
|
497
|
-
*
|
498
491
|
* _database_ のロックを強制的に解除する。
|
492
|
+
*
|
493
|
+
* @overload clear_lock
|
499
494
|
*/
|
500
495
|
static VALUE
|
501
496
|
rb_grn_database_clear_lock (VALUE self)
|
@@ -512,12 +507,9 @@ rb_grn_database_clear_lock (VALUE self)
|
|
512
507
|
}
|
513
508
|
|
514
509
|
/*
|
515
|
-
* Document-method: locked?
|
516
|
-
*
|
517
|
-
* call-seq:
|
518
|
-
* database.locked?
|
519
|
-
*
|
520
510
|
* _database_ がロックされていれば +true+ を返す。
|
511
|
+
*
|
512
|
+
* @overload locked?
|
521
513
|
*/
|
522
514
|
static VALUE
|
523
515
|
rb_grn_database_is_locked (VALUE self)
|
@@ -532,12 +524,9 @@ rb_grn_database_is_locked (VALUE self)
|
|
532
524
|
}
|
533
525
|
|
534
526
|
/*
|
535
|
-
* Document-method: touch
|
536
|
-
*
|
537
|
-
* call-seq:
|
538
|
-
* database.touch
|
539
|
-
*
|
540
527
|
* _database_ の最終更新時刻を現在時刻にする。
|
528
|
+
*
|
529
|
+
* @overload touch
|
541
530
|
*/
|
542
531
|
static VALUE
|
543
532
|
rb_grn_database_touch (VALUE self)
|
@@ -554,6 +543,7 @@ rb_grn_database_touch (VALUE self)
|
|
554
543
|
|
555
544
|
/*
|
556
545
|
* Defrags all variable size columns in the database.
|
546
|
+
*
|
557
547
|
* @return [Integer] the number of defraged segments
|
558
548
|
* @overload defrag(options={})
|
559
549
|
* @param [::Hash] options option for defrag
|
@@ -21,11 +21,11 @@
|
|
21
21
|
VALUE rb_cGrnDoubleArrayTrieCursor;
|
22
22
|
|
23
23
|
/*
|
24
|
-
* Document-class: Groonga::
|
24
|
+
* Document-class: Groonga::DoubleArrayTrieCursor < Groonga::TableCursor
|
25
25
|
*
|
26
|
-
* Groonga::
|
26
|
+
* {Groonga::DoubleArrayTrie} に登録されているレコードを順番に取り
|
27
27
|
* 出すためのオブジェクト。利用できるメソッドは
|
28
|
-
* Groonga::TableCursorとGroonga::TableCursor::KeySupportを
|
28
|
+
* {Groonga::TableCursor} と {Groonga::TableCursor::KeySupport} を
|
29
29
|
* 参照。
|
30
30
|
*/
|
31
31
|
|
@@ -30,22 +30,23 @@ VALUE rb_cGrnDoubleArrayTrie;
|
|
30
30
|
* trie. It can change key without ID change. This feature
|
31
31
|
* is supported by only Groonga::DoubleArrayTrie. But it
|
32
32
|
* requires large spaces rather than other tables. It is
|
33
|
-
* used by Groonga::Database for key management
|
33
|
+
* used by {Groonga::Database} for key management
|
34
34
|
* internally. It's reasonable choice because number of
|
35
|
-
* tables and columns in Groonga::Database (number of their
|
35
|
+
* tables and columns in {Groonga::Database} (number of their
|
36
36
|
* names equals to number of keys to be managed by
|
37
37
|
* Groonga::DoubleArrayTrie) will be less than number of
|
38
38
|
* records of user defined tables.
|
39
39
|
*
|
40
40
|
* Groonga::DoubleArrayTrie supports exact match search,
|
41
41
|
* predictive search and common prefix search like
|
42
|
-
* Groonga::PatriciaTrie. It also supports cursor API.
|
42
|
+
* {Groonga::PatriciaTrie} . It also supports cursor API.
|
43
43
|
*/
|
44
44
|
|
45
45
|
/*
|
46
46
|
* It creates a table that manages records by double array trie.
|
47
47
|
* ブロックを指定すると、そのブロックに生成したテーブルが渡さ
|
48
48
|
* れ、ブロックを抜けると自動的にテーブルが破棄される。
|
49
|
+
*
|
49
50
|
* @example
|
50
51
|
* #無名一時テーブルを生成する。
|
51
52
|
* Groonga::DoubleArrayTrie.create
|
@@ -69,12 +70,12 @@ VALUE rb_cGrnDoubleArrayTrie;
|
|
69
70
|
* #(キーの種類を表すオブジェクトは文字列で指定。)
|
70
71
|
* Groonga::DoubleArrayTrie.create(:key_type => "ShortText")
|
71
72
|
*
|
72
|
-
*
|
73
|
+
* #キーとしてBookmarksテーブルのレコードを使用す
|
73
74
|
* #る無名一時テーブルを生成する。
|
74
75
|
* bookmarks = Groonga::DoubleArrayTrie.create(:name => "Bookmarks")
|
75
76
|
* Groonga::DoubleArrayTrie.create(:key_type => bookmarks)
|
76
77
|
*
|
77
|
-
*
|
78
|
+
* #キーとしてBookmarksテーブルのレコードを使用す
|
78
79
|
* #る無名一時テーブルを生成する。
|
79
80
|
* #(テーブルは文字列で指定。)
|
80
81
|
* Groonga::DoubleArrayTrie.create(:name => "Bookmarks")
|
@@ -91,121 +92,67 @@ VALUE rb_cGrnDoubleArrayTrie;
|
|
91
92
|
*
|
92
93
|
* @overload create(options={})
|
93
94
|
* @return [Groonga::DoubleArrayTrie]
|
94
|
-
*
|
95
|
-
*
|
96
|
-
*
|
97
|
-
*
|
98
|
-
*
|
99
|
-
*
|
100
|
-
*
|
101
|
-
*
|
102
|
-
*
|
103
|
-
*
|
104
|
-
*
|
105
|
-
*
|
106
|
-
*
|
107
|
-
*
|
108
|
-
*
|
109
|
-
*
|
110
|
-
*
|
111
|
-
*
|
112
|
-
*
|
113
|
-
*
|
114
|
-
*
|
115
|
-
*
|
116
|
-
*
|
117
|
-
*
|
118
|
-
*
|
119
|
-
*
|
120
|
-
*
|
121
|
-
*
|
122
|
-
*
|
123
|
-
*
|
124
|
-
*
|
125
|
-
*
|
126
|
-
*
|
95
|
+
* @!macro [new] double-array-trie.create.options
|
96
|
+
* @param [::Hash] options The name and value
|
97
|
+
* pairs. Omitted names are initialized as the default value.
|
98
|
+
* @option options [Groonga::Context] :context (Groonga::Context.default)
|
99
|
+
* テーブルが利用する {Groonga::Context} 。
|
100
|
+
* @option options :name
|
101
|
+
* テーブルの名前。名前をつけると、 {Groonga::Context#[]} に名
|
102
|
+
* 前を指定してテーブルを取得することができる。省略すると
|
103
|
+
* 無名テーブルになり、テーブルIDでのみ取得できる。
|
104
|
+
* @option options :path
|
105
|
+
* テーブルを保存するパス。パスを指定すると永続テーブルとな
|
106
|
+
* り、プロセス終了後もレコードは保持される。次回起動時に
|
107
|
+
* {Groonga::Context#[]} で保存されたレコードを利用する
|
108
|
+
* ことができる。省略すると一時テーブルになり、プロセスが終
|
109
|
+
* 了するとレコードは破棄される。
|
110
|
+
* @option options :persistent
|
111
|
+
* +true+ を指定すると永続テーブルとなる。 +path+ を省略した
|
112
|
+
* 場合は自動的にパスが付加される。 +:context+ で指定した
|
113
|
+
* {Groonga::Context} に結びついているデータベースが一時デー
|
114
|
+
* タベースの場合は例外が発生する。
|
115
|
+
* @option options :key_normalize
|
116
|
+
* +true+ を指定するとキーを正規化する。
|
117
|
+
* @option options :key_with_sis
|
118
|
+
* +true+ を指定するとキーの文字列の全suffixが自動的に登
|
119
|
+
* 録される。
|
120
|
+
* @option options :key_type
|
121
|
+
* キーの種類を示すオブジェクトを指定する。キーの種類には型
|
122
|
+
* 名("Int32"や"ShortText"など)または {Groonga::Type} または
|
123
|
+
* テーブル( {Groonga::Array} 、{Groonga::Hash} 、
|
124
|
+
* {Groonga::DoubleArrayTrie} のどれか)を指定する。
|
125
|
+
* {Groonga::Type} を指定した場合は、その型が示す範囲の値をキー
|
126
|
+
* として使用する。ただし、キーの最大サイズは4096バイトで
|
127
|
+
* あるため、 {Groonga::Type::TEXT} や {Groonga::Type::LONG_TEXT}
|
128
|
+
* は使用できない。
|
127
129
|
*
|
128
|
-
*
|
129
|
-
*
|
130
|
-
*
|
131
|
-
*
|
130
|
+
* テーブルを指定した場合はレコードIDをキーとして使用する。
|
131
|
+
* 指定したテーブルの {Groonga::Record} をキーとして使用するこ
|
132
|
+
* ともでき、その場合は自動的に {Groonga::Record} からレコード
|
133
|
+
* IDを取得する。
|
132
134
|
*
|
133
|
-
*
|
134
|
-
*
|
135
|
-
*
|
136
|
-
*
|
137
|
-
*
|
135
|
+
* 省略した場合はShortText型をキーとして使用する。この場合、
|
136
|
+
* 4096バイトまで使用可能である。
|
137
|
+
* @option options :value_type
|
138
|
+
* 値の型を指定する。省略すると値のための領域を確保しない。
|
139
|
+
* 値を保存したい場合は必ず指定すること。
|
138
140
|
*
|
139
|
-
*
|
141
|
+
* 参考: {Groonga::Type.new}
|
140
142
|
*
|
141
|
-
*
|
142
|
-
*
|
143
|
-
*
|
144
|
-
*
|
145
|
-
*
|
146
|
-
*
|
147
|
-
*
|
148
|
-
*
|
149
|
-
*
|
143
|
+
* @option options :default_tokenizer
|
144
|
+
* {Groonga::IndexColumn} で使用するトークナイザを指定する。
|
145
|
+
* デフォルトでは何も設定されていないので、テーブルに
|
146
|
+
* {Groonga::IndexColumn} を定義する場合は
|
147
|
+
* @"TokenBigram"@ などを指定する必要がある。
|
148
|
+
* @option options :sub_records
|
149
|
+
* +true+ を指定すると {#group} でグループ化したときに、
|
150
|
+
* {Groonga::Record#n_sub_records} でグループに含まれるレコー
|
151
|
+
* ドの件数を取得できる。
|
152
|
+
* @!macro double-array-trie.create.options
|
150
153
|
* @overload create(options={})
|
151
154
|
* @yield [table]
|
152
|
-
*
|
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
|
-
*
|
155
|
+
* @!macro double-array-trie.create.options
|
209
156
|
*/
|
210
157
|
static VALUE
|
211
158
|
rb_grn_double_array_trie_s_create (int argc, VALUE *argv, VALUE klass)
|
@@ -288,11 +235,12 @@ rb_grn_double_array_trie_s_create (int argc, VALUE *argv, VALUE klass)
|
|
288
235
|
|
289
236
|
/*
|
290
237
|
* _key_ にマッチするレコードのIDがキーに入っている
|
291
|
-
* Groonga::Hashを返す。マッチするレコードがない場合は空の
|
292
|
-
*
|
238
|
+
* {Groonga::Hash} を返す。マッチするレコードがない場合は空の
|
239
|
+
* {fGroonga::Hash} が返る。
|
293
240
|
* _options_ で +:result+ を指定することにより、そのテーブルにマッ
|
294
241
|
* チしたレコードIDがキーのレコードを追加することができる。
|
295
242
|
* +:result+ にテーブルを指定した場合は、そのテーブルが返る。
|
243
|
+
*
|
296
244
|
* @example 複数のキーで検索し、結果を1つのテーブルに集める。
|
297
245
|
* result = nil
|
298
246
|
* keys = ["morita", "gunyara-kun", "yu"]
|
@@ -314,18 +262,19 @@ rb_grn_double_array_trie_s_create (int argc, VALUE *argv, VALUE klass)
|
|
314
262
|
* @option options :operator (Groonga::Operator::OR)
|
315
263
|
* マッチしたレコードをどのように扱うか。指定可能な値は以
|
316
264
|
* 下の通り。
|
317
|
-
*
|
265
|
+
*
|
266
|
+
* - Groonga::Operator::OR :=
|
318
267
|
* マッチしたレコードを追加。すでにレコードが追加され
|
319
|
-
* ている場合は何もしない。
|
320
|
-
*
|
268
|
+
* ている場合は何もしない。 =:
|
269
|
+
* - Groonga::Operator::AND :=
|
321
270
|
* マッチしたレコードのスコアを増加。マッチしなかった
|
322
|
-
* レコードを削除。
|
323
|
-
*
|
324
|
-
* マッチしたレコードを削除。
|
325
|
-
*
|
326
|
-
* マッチしたレコードのスコアを増加。
|
327
|
-
*
|
328
|
-
* ?????
|
271
|
+
* レコードを削除。 =:
|
272
|
+
* - Groonga::Operator::BUT :=
|
273
|
+
* マッチしたレコードを削除。 =:
|
274
|
+
* - Groonga::Operator::ADJUST :=
|
275
|
+
* マッチしたレコードのスコアを増加。 =:
|
276
|
+
* - +:type+ :=
|
277
|
+
* ????? =:
|
329
278
|
*
|
330
279
|
*/
|
331
280
|
static VALUE
|