rroonga 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -30,10 +30,9 @@ VALUE rb_mGrnEncodingSupport;
|
|
30
30
|
*/
|
31
31
|
|
32
32
|
/*
|
33
|
-
* call-seq:
|
34
|
-
* object.encoding -> エンコーディング
|
35
|
-
*
|
36
33
|
* オブジェクトのエンコーディングを返す。
|
34
|
+
* @overload encoding
|
35
|
+
* @return [Groonga::Encoding] オブジェクトのエンコーディング
|
37
36
|
*/
|
38
37
|
static VALUE
|
39
38
|
rb_grn_encoding_support_get_encoding (VALUE self)
|
@@ -183,13 +183,19 @@ rb_grn_encoding_to_ruby_encoding (grn_encoding encoding)
|
|
183
183
|
|
184
184
|
return rb_encoding;
|
185
185
|
}
|
186
|
+
|
187
|
+
VALUE
|
188
|
+
rb_grn_encoding_to_ruby_encoding_object (grn_encoding encoding)
|
189
|
+
{
|
190
|
+
rb_encoding *rb_encoding = rb_grn_encoding_to_ruby_encoding(encoding);
|
191
|
+
return rb_enc_from_encoding(rb_encoding);
|
192
|
+
}
|
186
193
|
#endif
|
187
194
|
|
188
195
|
/*
|
189
|
-
* call-seq:
|
190
|
-
* Groonga::Encoding.default -> エンコーディング
|
191
|
-
*
|
192
196
|
* デフォルトのエンコーディングを返す。
|
197
|
+
* @overload default
|
198
|
+
* @return [Groonga::Encoding] デフォルトのエンコーディング
|
193
199
|
*/
|
194
200
|
static VALUE
|
195
201
|
rb_grn_encoding_s_get_default (VALUE self)
|
@@ -198,11 +204,10 @@ rb_grn_encoding_s_get_default (VALUE self)
|
|
198
204
|
}
|
199
205
|
|
200
206
|
/*
|
201
|
-
*
|
202
|
-
*
|
203
|
-
*
|
204
|
-
*
|
205
|
-
* の指定方法はGroonga::Encodingを参照。
|
207
|
+
* デフォルトのエンコーディングを設定する。
|
208
|
+
* @overload default=(encoding)
|
209
|
+
* @param [Groonga::Encoding] encoding 指定するエンコーディング。
|
210
|
+
* エンコーディングの指定方法はGroonga::Encodingを参照。
|
206
211
|
*/
|
207
212
|
static VALUE
|
208
213
|
rb_grn_encoding_s_set_default (VALUE self, VALUE rb_encoding)
|
@@ -605,7 +605,7 @@ rb_grn_init_exception (VALUE mGrn)
|
|
605
605
|
* groongaレベルでは破棄されているが、Rubyレベルでは生き
|
606
606
|
* ているオブジェクトにアクセスすると発生する。
|
607
607
|
*
|
608
|
-
* @deprecated since 1.2.3.
|
608
|
+
* @deprecated Use {Closed} instead since 1.2.3.
|
609
609
|
*/
|
610
610
|
rb_define_const(mGrn, "ObjectClosed", rb_eGrnClosed);
|
611
611
|
|
@@ -107,20 +107,17 @@ rb_grn_expression_initialize (int argc, VALUE *argv, VALUE self)
|
|
107
107
|
}
|
108
108
|
|
109
109
|
/*
|
110
|
-
* call-seq:
|
111
|
-
* expression.define_variable(options={}) -> Groonga::Variable
|
112
|
-
*
|
113
110
|
* _expression_ で使用可能な変数を作成する。
|
114
111
|
*
|
115
|
-
*
|
116
|
-
*
|
117
|
-
*
|
118
|
-
*
|
119
|
-
*
|
120
|
-
*
|
121
|
-
*
|
112
|
+
* @overload define_variable(options={})
|
113
|
+
* @param [::Hash] options The name and value
|
114
|
+
* pairs. Omitted names are initialized as the default value.
|
115
|
+
* @option options :name (false)
|
116
|
+
* 変数の名前。省略した場合は名前を付けない。
|
117
|
+
* @option options :domain
|
118
|
+
* テーブルを指定すると、そのテーブル用のレコードとして初期化する。
|
119
|
+
* @return [Groonga::Variable]
|
122
120
|
*
|
123
|
-
* テーブルを指定すると、そのテーブル用のレコードとして初期化する。
|
124
121
|
*/
|
125
122
|
static VALUE
|
126
123
|
rb_grn_expression_define_variable (int argc, VALUE *argv, VALUE self)
|
@@ -160,12 +157,14 @@ rb_grn_expression_define_variable (int argc, VALUE *argv, VALUE self)
|
|
160
157
|
}
|
161
158
|
|
162
159
|
/*
|
163
|
-
* call-seq:
|
164
|
-
* expression.append_object(object,
|
165
|
-
* operation=Groonga::Operator::PUSH,
|
166
|
-
* n_arguments=1) -> self
|
167
|
-
*
|
168
160
|
* _object_ を追加し、 _n_arguments_ 個の引数を取る _operation_ を追加する。
|
161
|
+
*
|
162
|
+
* @overload append_object(object, operation=Groonga::Operator::PUSH, n_arguments=1)
|
163
|
+
* @param [Object] object 追加するオブジェクト
|
164
|
+
* @param [Groonga::Operator::XXX] operation 追加する _operation_
|
165
|
+
* @param [Integer] n_arguments _operation_ の取る引数
|
166
|
+
* @return [Self] self
|
167
|
+
*
|
169
168
|
*/
|
170
169
|
static VALUE
|
171
170
|
rb_grn_expression_append_object (int argc, VALUE *argv, VALUE self)
|
@@ -196,12 +195,13 @@ rb_grn_expression_append_object (int argc, VALUE *argv, VALUE self)
|
|
196
195
|
}
|
197
196
|
|
198
197
|
/*
|
199
|
-
* call-seq:
|
200
|
-
* expression.append_constant(constant,
|
201
|
-
* operation=Groonga::Operator::PUSH,
|
202
|
-
* n_arguments=1) -> self
|
203
|
-
*
|
204
198
|
* _constant_ を追加し、 _n_arguments_ 個の引数を取る _operation_ を追加する。
|
199
|
+
*
|
200
|
+
* @overload append_constant(constant, operation=Groonga::Operator::PUSH, n_arguments=1)
|
201
|
+
* @param [Object] constant 追加する _constant_
|
202
|
+
* @param [Groonga::Operator::XXX] operation 追加する _operation_
|
203
|
+
* @param [Integer] n_arguments _operation_ の取る引数
|
204
|
+
* @return [Self] self
|
205
205
|
*/
|
206
206
|
static VALUE
|
207
207
|
rb_grn_expression_append_constant (int argc, VALUE *argv, VALUE self)
|
@@ -261,87 +261,71 @@ rb_grn_expression_append_operation (VALUE self, VALUE rb_operation,
|
|
261
261
|
}
|
262
262
|
|
263
263
|
/*
|
264
|
-
* call-seq:
|
265
|
-
* expression.parse(query, options={})
|
266
|
-
*
|
267
264
|
* 文字列 _query_ をパースする。
|
268
|
-
*
|
269
|
-
*
|
270
|
-
*
|
271
|
-
*
|
272
|
-
*
|
273
|
-
*
|
274
|
-
*
|
275
|
-
*
|
276
|
-
*
|
277
|
-
*
|
278
|
-
*
|
279
|
-
*
|
280
|
-
*
|
281
|
-
*
|
282
|
-
*
|
283
|
-
*
|
284
|
-
*
|
285
|
-
*
|
286
|
-
*
|
287
|
-
*
|
288
|
-
*
|
289
|
-
*
|
290
|
-
*
|
291
|
-
*
|
292
|
-
*
|
293
|
-
*
|
294
|
-
*
|
295
|
-
*
|
296
|
-
*
|
297
|
-
*
|
298
|
-
*
|
299
|
-
*
|
300
|
-
*
|
301
|
-
*
|
302
|
-
*
|
303
|
-
*
|
304
|
-
*
|
305
|
-
*
|
265
|
+
* @overload parse(query, options={})
|
266
|
+
* @param [String] query パースする文字列
|
267
|
+
* @param [::Hash] options The name and value
|
268
|
+
* pairs. Omitted names are initialized as the default value.
|
269
|
+
* @option options :default_column
|
270
|
+
* "column_name:hoge"ではなく"hoge"のようにcolumn_nameが指
|
271
|
+
* 定されない条件の検索対象となるカラムを指定する。
|
272
|
+
* @option options :default_operator (Groonga::Operator::AND)
|
273
|
+
* "+"や"OR"で繋がれず、ただ列挙された複数の条件があった時、
|
274
|
+
* _expression_ 全体として各レコードをヒットとみなすかの論理
|
275
|
+
* 条件を指定する。省略した場合はGroonga::Operator::AND。
|
276
|
+
*
|
277
|
+
* - Groonga::Operator::OR :=
|
278
|
+
* レコードはいずれかの条件にマッチすればいい。 =:
|
279
|
+
* - Groonga::Operator::AND :=
|
280
|
+
* レコードは全ての条件にマッチしなければならない。 =:
|
281
|
+
* - Groonga::Operator::BUT :=
|
282
|
+
* 最初の条件にレコードはマッチし、残りの条件にレコードは
|
283
|
+
* マッチしてはならない。 =:
|
284
|
+
*
|
285
|
+
* @option options :default_mode (Groonga::Operator::MATCH)
|
286
|
+
* 検索時のモードを指定する。省略した場合はGroonga::Operator::MATCH。
|
287
|
+
* (FIXME: モードによってどういう動作になるかを書く。)
|
288
|
+
* @option options :syntax (:query)
|
289
|
+
* _query_ の構文を指定する。指定可能な値は以下の通り。省略
|
290
|
+
* した場合は +:query+ 。
|
291
|
+
*
|
292
|
+
* - +:query+ :=
|
293
|
+
* 「文字列1 OR 文字列2」で「"文字列1"あるいは"文字列2"
|
294
|
+
* にマッチという検索エンジンで利用できるような構文を使
|
295
|
+
* う。
|
296
|
+
* 参考: grn式のquery形式(link:text/expression_rdoc.html) =:
|
297
|
+
* - +nil+ :=
|
298
|
+
* +:query+と同様 =:
|
299
|
+
* - +:script+ :=
|
300
|
+
* 「[カラム名] == [値]」というようにECMAScript風の構文を使う。
|
301
|
+
* 参考: grn式のscript形式(link:text/expression_rdoc.html) =:
|
302
|
+
* @option options :allow_pragma
|
303
|
+
* _query_ の構文に query を用いているとき( +:syntax+
|
304
|
+
* オプション参照)、「*E-1」というようにクエリの先頭で
|
305
|
+
* pragmaを利用できるようにする。script構文を用いている
|
306
|
+
* ときはこのオプションを利用できない。
|
307
|
+
*
|
308
|
+
* デフォルトではプラグマを利用できる。
|
306
309
|
*
|
307
310
|
* 参考: grn式のquery形式(link:text/expression_rdoc.html)
|
308
|
-
*
|
309
|
-
*
|
310
|
-
*
|
311
|
+
* @option options :allow_column
|
312
|
+
* _query_ の構文にqueryを用いているとき( +:syntax+ オプショ
|
313
|
+
* ン参照)、「カラム名:値」というようにカラム名を指定した
|
314
|
+
* 条件式を利用できるようにする。script構文を用いていると
|
315
|
+
* きはこのオプションを利用できない。
|
311
316
|
*
|
312
|
-
*
|
317
|
+
* デフォルトではカラム名を指定した条件式を利用できる。
|
313
318
|
*
|
314
|
-
*
|
315
|
-
*
|
316
|
-
*
|
317
|
-
*
|
318
|
-
*
|
319
|
-
*
|
320
|
-
* デフォルトではプラグマを利用できる。
|
321
|
-
*
|
322
|
-
* 参考: grn式のquery形式(link:text/expression_rdoc.html)
|
323
|
-
*
|
324
|
-
* @option options :allow_column The allow_column
|
325
|
-
*
|
326
|
-
* _query_ の構文にqueryを用いているとき(+:syntax+オプショ
|
327
|
-
* ン参照)、「カラム名:値」というようにカラム名を指定した
|
328
|
-
* 条件式を利用できるようにする。script構文を用いていると
|
329
|
-
* きはこのオプションを利用できない。
|
330
|
-
*
|
331
|
-
* デフォルトではカラム名を指定した条件式を利用できる。
|
332
|
-
*
|
333
|
-
* 参考: grn式のquery形式(link:text/expression_rdoc.html)
|
334
|
-
*
|
335
|
-
* @option options :allow_update The allow_update
|
336
|
-
*
|
337
|
-
* _query_の構文にscriptを用いているとき( +:syntax+ オプショ
|
338
|
-
* ン参照)、「カラム名 = 値」というように更新操作を利用で
|
339
|
-
* きるようにする。query構文を用いているときはこのオプショ
|
340
|
-
* ンを利用できない。
|
319
|
+
* 参考: grn式のquery形式(link:text/expression_rdoc.html)
|
320
|
+
* @option options :allow_update
|
321
|
+
* _query_ の構文にscriptを用いているとき( +:syntax+ オプショ
|
322
|
+
* ン参照)、「カラム名 = 値」というように更新操作を利用で
|
323
|
+
* きるようにする。query構文を用いているときはこのオプショ
|
324
|
+
* ンを利用できない。
|
341
325
|
*
|
342
|
-
*
|
326
|
+
* デフォルトでは更新操作を利用できる。
|
343
327
|
*
|
344
|
-
*
|
328
|
+
* 参考: grn式のscript形式(link:text/expression_rdoc.html)
|
345
329
|
*/
|
346
330
|
static VALUE
|
347
331
|
rb_grn_expression_parse (int argc, VALUE *argv, VALUE self)
|
@@ -578,20 +562,17 @@ rb_grn_expression_inspect (VALUE self)
|
|
578
562
|
}
|
579
563
|
|
580
564
|
/*
|
581
|
-
*
|
582
|
-
* expression.snippet(tags, options) -> Groonga::Snippet
|
583
|
-
*
|
584
|
-
* _expression_ からGroonga::Snippetを生成する。 _tags_ には
|
565
|
+
* _expression_ から {Groonga::Snippet} を生成する。 _tags_ には
|
585
566
|
* キーワードの前後に挿入するタグの配列を以下のような形式で指定
|
586
567
|
* する。
|
587
568
|
*
|
588
569
|
* <pre>
|
589
570
|
* !!!ruby
|
590
|
-
*
|
591
|
-
*
|
592
|
-
*
|
593
|
-
*
|
594
|
-
*
|
571
|
+
* [
|
572
|
+
* ["キーワード前に挿入する文字列1", "キーワード後に挿入する文字列1"],
|
573
|
+
* ["キーワード前に挿入する文字列2", "キーワード後に挿入する文字列2"],
|
574
|
+
* # ...,
|
575
|
+
* ]
|
595
576
|
* </pre>
|
596
577
|
*
|
597
578
|
* もし、1つのスニペットの中に _tags_ で指定したタグより多くの
|
@@ -600,37 +581,33 @@ rb_grn_expression_inspect (VALUE self)
|
|
600
581
|
*
|
601
582
|
* <pre>
|
602
583
|
* !!!ruby
|
603
|
-
*
|
604
|
-
*
|
605
|
-
*
|
606
|
-
*
|
607
|
-
*
|
608
|
-
*
|
584
|
+
* expression.parse("Ruby groonga 検索")
|
585
|
+
* tags = [["<tag1>", "</tag1>"], ["<tag2>", "</tag2>"]]
|
586
|
+
* snippet = expression.snippet(tags)
|
587
|
+
* p snippet.execute("Rubyでgroonga使って全文検索、高速検索。")
|
588
|
+
* # => ["<tag1>Ruby</tag1>で<tag2>groonga</tag2>"
|
589
|
+
* # => "使って全文<tag1>検索</tag1>、高速<tag2>検索</tag2>。"]
|
609
590
|
* </pre>
|
610
591
|
*
|
611
|
-
*
|
612
|
-
*
|
613
|
-
*
|
614
|
-
*
|
615
|
-
*
|
616
|
-
*
|
617
|
-
*
|
618
|
-
*
|
619
|
-
*
|
620
|
-
*
|
621
|
-
*
|
622
|
-
*
|
623
|
-
*
|
624
|
-
*
|
625
|
-
*
|
626
|
-
*
|
627
|
-
*
|
628
|
-
*
|
629
|
-
*
|
630
|
-
* @option options :html_escape (false) The html_escape
|
631
|
-
*
|
632
|
-
* スニペット内の +<+, +>+, +&+, +"+ をHTMLエスケープするか
|
633
|
-
* どうか。省略した場合は +false+ で、HTMLエスケープしない。
|
592
|
+
* @overload snippet(tags, options)
|
593
|
+
* @param tags [Array<string>] キーワードの前後に挿入するタグの配列
|
594
|
+
* (詳細は上記を参照)
|
595
|
+
* @param options [::Hash] The name and value
|
596
|
+
* pairs. Omitted names are initialized as the default value.
|
597
|
+
* @option options :normalize (false)
|
598
|
+
* キーワード文字列・スニペット元の文字列を正規化するかど
|
599
|
+
* うか。省略した場合は +false+ で正規化しない。
|
600
|
+
* @option options :skip_leading_spaces (false)
|
601
|
+
* 先頭の空白を無視するかどうか。省略した場合は +false+ で無
|
602
|
+
* 視しない。
|
603
|
+
* @option options :width (100)
|
604
|
+
* スニペット文字列の長さ。省略した場合は100文字。
|
605
|
+
* @option options :max_results (3)
|
606
|
+
* 生成するスニペットの最大数。省略した場合は3。
|
607
|
+
* @option options :html_escape (false)
|
608
|
+
* スニペット内の +<+, +>+, +&+, +"+ をHTMLエスケープするか
|
609
|
+
* どうか。省略した場合は +false+ で、HTMLエスケープしない。
|
610
|
+
* @return [Groonga::Snippet]
|
634
611
|
*/
|
635
612
|
static VALUE
|
636
613
|
rb_grn_expression_snippet (int argc, VALUE *argv, VALUE self)
|
@@ -56,10 +56,11 @@ rb_grn_fix_size_column_array_reference (VALUE self, VALUE rb_id)
|
|
56
56
|
}
|
57
57
|
|
58
58
|
/*
|
59
|
-
* call-seq:
|
60
|
-
* column[id] = value
|
61
|
-
*
|
62
59
|
* _column_ の _id_ に対応する値を設定する。
|
60
|
+
*
|
61
|
+
* @overload []=(id, value)
|
62
|
+
* @param [Integer] id 設定する値に対応する _column_ の _id_
|
63
|
+
* @param [Groonga::Object] value 設定する値
|
63
64
|
*/
|
64
65
|
static VALUE
|
65
66
|
rb_grn_fix_size_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
|
@@ -77,7 +78,7 @@ rb_grn_fix_size_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
|
|
77
78
|
&value, &range_id, &range);
|
78
79
|
|
79
80
|
id = NUM2UINT(rb_id);
|
80
|
-
|
81
|
+
RVAL2GRNVALUE(rb_value, context, value, range_id, range);
|
81
82
|
|
82
83
|
rc = grn_obj_set_value(context, column, id, value, GRN_OBJ_SET);
|
83
84
|
rb_grn_context_check(context, self);
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/* -*- coding: utf-8; c-file-style: "ruby" -*- */
|
2
|
+
/*
|
3
|
+
Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
4
|
+
|
5
|
+
This library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
7
|
+
License version 2.1 as published by the Free Software Foundation.
|
8
|
+
|
9
|
+
This library is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
Lesser General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Lesser General Public
|
15
|
+
License along with this library; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "rb-grn.h"
|
20
|
+
|
21
|
+
VALUE rb_cGrnTokyoGeoPoint;
|
22
|
+
VALUE rb_cGrnWGS84GeoPoint;
|
23
|
+
|
24
|
+
VALUE
|
25
|
+
rb_grn_tokyo_geo_point_new (int latitude, int longitude)
|
26
|
+
{
|
27
|
+
return rb_grn_tokyo_geo_point_new_raw(INT2NUM(latitude), INT2NUM(longitude));
|
28
|
+
}
|
29
|
+
|
30
|
+
VALUE
|
31
|
+
rb_grn_wgs84_geo_point_new (int latitude, int longitude)
|
32
|
+
{
|
33
|
+
return rb_grn_wgs84_geo_point_new_raw(INT2NUM(latitude), INT2NUM(longitude));
|
34
|
+
}
|
35
|
+
|
36
|
+
VALUE
|
37
|
+
rb_grn_tokyo_geo_point_new_raw (VALUE latitude, VALUE longitude)
|
38
|
+
{
|
39
|
+
return rb_funcall(rb_cGrnTokyoGeoPoint, rb_intern("new"), 2,
|
40
|
+
latitude, longitude);
|
41
|
+
}
|
42
|
+
|
43
|
+
VALUE
|
44
|
+
rb_grn_wgs84_geo_point_new_raw (VALUE latitude, VALUE longitude)
|
45
|
+
{
|
46
|
+
return rb_funcall(rb_cGrnWGS84GeoPoint, rb_intern("new"), 2,
|
47
|
+
latitude, longitude);
|
48
|
+
}
|
49
|
+
|
50
|
+
void
|
51
|
+
rb_grn_init_geo_point (VALUE mGrn)
|
52
|
+
{
|
53
|
+
rb_cGrnTokyoGeoPoint = rb_const_get(mGrn, rb_intern("TokyoGeoPoint"));
|
54
|
+
rb_cGrnWGS84GeoPoint = rb_const_get(mGrn, rb_intern("WGS84GeoPoint"));
|
55
|
+
}
|
data/ext/groonga/rb-grn-hash.c
CHANGED
@@ -30,81 +30,10 @@ VALUE rb_cGrnHash;
|
|
30
30
|
*/
|
31
31
|
|
32
32
|
/*
|
33
|
-
* call-seq:
|
34
|
-
* Groonga::Hash.create(options={}) -> Groonga::Hash
|
35
|
-
* Groonga::Hash.create(options={}) {|table| ... }
|
36
|
-
*
|
37
33
|
* 各レコードをキーで管理するテーブルを生成する。ブロックを指
|
38
34
|
* 定すると、そのブロックに生成したテーブルが渡され、ブロック
|
39
35
|
* を抜けると自動的にテーブルが破棄される。
|
40
36
|
*
|
41
|
-
* _options_ に指定可能な値は以下の通り。
|
42
|
-
* @param [::Hash] options The name and value
|
43
|
-
* pairs. Omitted names are initialized as the default value
|
44
|
-
* @option options [Groonga::Context] :context (Groonga::Context.default) The context
|
45
|
-
*
|
46
|
-
* テーブルが利用するGroonga::Context。省略すると
|
47
|
-
* Groonga::Context.defaultを用いる。
|
48
|
-
* @option options [Groonga::Context#[]] :name The name
|
49
|
-
*
|
50
|
-
* テーブルの名前。名前をつけると、Groonga::Context#[]に名
|
51
|
-
* 前を指定してテーブルを取得することができる。省略すると
|
52
|
-
* 無名テーブルになり、テーブルIDでのみ取得できる。
|
53
|
-
*
|
54
|
-
* @option options [Groonga::Context#[]] :path The path
|
55
|
-
*
|
56
|
-
* テーブルを保存するパス。パスを指定すると永続テーブルとな
|
57
|
-
* り、プロセス終了後もレコードは保持される。次回起動時に
|
58
|
-
* Groonga::Context#[]で保存されたレコードを利用することが
|
59
|
-
* できる。省略すると一時テーブルになり、プロセスが終了する
|
60
|
-
* とレコードは破棄される。
|
61
|
-
*
|
62
|
-
* @option options :persistent The persistent
|
63
|
-
* +true+ を指定すると永続テーブルとなる。 +path+ を省略した
|
64
|
-
* 場合は自動的にパスが付加される。 +:context+ で指定した
|
65
|
-
* Groonga::Contextに結びついているデータベースが一時デー
|
66
|
-
* タベースの場合は例外が発生する。
|
67
|
-
*
|
68
|
-
* @option options :key_normalize The normalize
|
69
|
-
* +true+ を指定するとキーを正規化する。
|
70
|
-
*
|
71
|
-
* @option options :key_type The key_type
|
72
|
-
* キーの種類を示すオブジェクトを指定する。キーの種類には型
|
73
|
-
* 名("Int32"や"ShortText"など)またはGroonga::Typeまたは
|
74
|
-
* テーブル(Groonga::Array、Groonga::Hash、
|
75
|
-
* Groonga::PatriciaTrieのどれか)を指定する。
|
76
|
-
*
|
77
|
-
* Groonga::Typeを指定した場合は、その型が示す範囲の値をキー
|
78
|
-
* として使用する。ただし、キーの最大サイズは4096バイトで
|
79
|
-
* あるため、Groonga::Type::TEXTやGroonga::Type::LONG_TEXT
|
80
|
-
* は使用できない。
|
81
|
-
*
|
82
|
-
* テーブルを指定した場合はレコードIDをキーとして使用する。
|
83
|
-
* 指定したテーブルのGroonga::Recordをキーとして使用するこ
|
84
|
-
* ともでき、その場合は自動的にGroonga::Recordからレコード
|
85
|
-
* IDを取得する。
|
86
|
-
*
|
87
|
-
* 省略した場合はShortText型をキーとして使用する。この場合、
|
88
|
-
* 4096バイトまで使用可能である。
|
89
|
-
*
|
90
|
-
* @option options :value_type The value_type
|
91
|
-
*
|
92
|
-
* 値の型を指定する。省略すると値のための領域を確保しない。
|
93
|
-
* 値を保存したい場合は必ず指定すること。
|
94
|
-
*
|
95
|
-
* 参考: Groonga::Type.new
|
96
|
-
*
|
97
|
-
* @option options [Groonga::IndexColumn] :default_tokenizer The default_tokenizer
|
98
|
-
* Groonga::IndexColumnで使用するトークナイザを指定する。
|
99
|
-
* デフォルトでは何も設定されていないので、テーブルに
|
100
|
-
* Groonga::IndexColumnを定義する場合は
|
101
|
-
* <tt>"TokenBigram"</tt>などを指定する必要がある。
|
102
|
-
*
|
103
|
-
* @option options [Groonga::Record#n_sub_records] :sub_records The sub_records
|
104
|
-
* +true+ を指定すると#groupでグループ化したときに、
|
105
|
-
* Groonga::Record#n_sub_recordsでグループに含まれるレコー
|
106
|
-
* ドの件数を取得できる。
|
107
|
-
*
|
108
37
|
* @example
|
109
38
|
* #無名一時テーブルを生成する。
|
110
39
|
* Groonga::Hash.create
|
@@ -144,6 +73,119 @@ VALUE rb_cGrnHash;
|
|
144
73
|
* :default_tokenizer => "TokenBigram")
|
145
74
|
* terms.define_index_column("content", bookmarks,
|
146
75
|
* :source => "Bookmarks.comment")
|
76
|
+
*
|
77
|
+
* @overload create(options={})
|
78
|
+
* @return [Groonga::Hash]
|
79
|
+
* @param [::Hash] options The name and value
|
80
|
+
* pairs. Omitted names are initialized as the default value
|
81
|
+
* @option options [Groonga::Context] :context (Groonga::Context.default)
|
82
|
+
* テーブルが利用するGroonga::Context。省略すると
|
83
|
+
* Groonga::Context.defaultを用いる。
|
84
|
+
* @option options [Groonga::Context#[]] :name
|
85
|
+
* テーブルの名前。名前をつけると、Groonga::Context#[]に名
|
86
|
+
* 前を指定してテーブルを取得することができる。省略すると
|
87
|
+
* 無名テーブルになり、テーブルIDでのみ取得できる。
|
88
|
+
* @option options [Groonga::Context#[]] :path
|
89
|
+
* テーブルを保存するパス。パスを指定すると永続テーブルとな
|
90
|
+
* り、プロセス終了後もレコードは保持される。次回起動時に
|
91
|
+
* Groonga::Context#[]で保存されたレコードを利用することが
|
92
|
+
* できる。省略すると一時テーブルになり、プロセスが終了する
|
93
|
+
* とレコードは破棄される。
|
94
|
+
* @option options :persistent
|
95
|
+
* +true+ を指定すると永続テーブルとなる。 +path+ を省略した
|
96
|
+
* 場合は自動的にパスが付加される。 +:context+ で指定した
|
97
|
+
* Groonga::Contextに結びついているデータベースが一時デー
|
98
|
+
* タベースの場合は例外が発生する。
|
99
|
+
* @option options :key_normalize
|
100
|
+
* +true+ を指定するとキーを正規化する。
|
101
|
+
* @option options :key_type
|
102
|
+
* キーの種類を示すオブジェクトを指定する。キーの種類には型
|
103
|
+
* 名("Int32"や"ShortText"など)またはGroonga::Typeまたは
|
104
|
+
* テーブル(Groonga::Array、Groonga::Hash、
|
105
|
+
* Groonga::PatriciaTrieのどれか)を指定する。
|
106
|
+
*
|
107
|
+
* Groonga::Typeを指定した場合は、その型が示す範囲の値をキー
|
108
|
+
* として使用する。ただし、キーの最大サイズは4096バイトで
|
109
|
+
* あるため、Groonga::Type::TEXTやGroonga::Type::LONG_TEXT
|
110
|
+
* は使用できない。
|
111
|
+
*
|
112
|
+
* テーブルを指定した場合はレコードIDをキーとして使用する。
|
113
|
+
* 指定したテーブルのGroonga::Recordをキーとして使用するこ
|
114
|
+
* ともでき、その場合は自動的にGroonga::Recordからレコード
|
115
|
+
* IDを取得する。
|
116
|
+
*
|
117
|
+
* 省略した場合はShortText型をキーとして使用する。この場合、
|
118
|
+
* 4096バイトまで使用可能である。
|
119
|
+
* @option options :value_type
|
120
|
+
* 値の型を指定する。省略すると値のための領域を確保しない。
|
121
|
+
* 値を保存したい場合は必ず指定すること。
|
122
|
+
*
|
123
|
+
* 参考: Groonga::Type.new
|
124
|
+
* @option options [Groonga::IndexColumn] :default_tokenizer
|
125
|
+
* Groonga::IndexColumnで使用するトークナイザを指定する。
|
126
|
+
* デフォルトでは何も設定されていないので、テーブルに
|
127
|
+
* Groonga::IndexColumnを定義する場合は
|
128
|
+
* <tt>"TokenBigram"</tt>などを指定する必要がある。
|
129
|
+
* @option options [Groonga::Record#n_sub_records] :sub_records
|
130
|
+
* +true+ を指定すると#groupでグループ化したときに、
|
131
|
+
* Groonga::Record#n_sub_recordsでグループに含まれるレコー
|
132
|
+
* ドの件数を取得できる。
|
133
|
+
* @overload create(options={})
|
134
|
+
* @yield [table]
|
135
|
+
* @param [::Hash] options The name and value
|
136
|
+
* pairs. Omitted names are initialized as the default value
|
137
|
+
* @option options [Groonga::Context] :context (Groonga::Context.default)
|
138
|
+
* テーブルが利用するGroonga::Context。省略すると
|
139
|
+
* Groonga::Context.defaultを用いる。
|
140
|
+
* @option options [Groonga::Context#[]] :name
|
141
|
+
* テーブルの名前。名前をつけると、Groonga::Context#[]に名
|
142
|
+
* 前を指定してテーブルを取得することができる。省略すると
|
143
|
+
* 無名テーブルになり、テーブルIDでのみ取得できる。
|
144
|
+
* @option options [Groonga::Context#[]] :path
|
145
|
+
* テーブルを保存するパス。パスを指定すると永続テーブルとな
|
146
|
+
* り、プロセス終了後もレコードは保持される。次回起動時に
|
147
|
+
* Groonga::Context#[]で保存されたレコードを利用することが
|
148
|
+
* できる。省略すると一時テーブルになり、プロセスが終了する
|
149
|
+
* とレコードは破棄される。
|
150
|
+
* @option options :persistent
|
151
|
+
* +true+ を指定すると永続テーブルとなる。 +path+ を省略した
|
152
|
+
* 場合は自動的にパスが付加される。 +:context+ で指定した
|
153
|
+
* Groonga::Contextに結びついているデータベースが一時デー
|
154
|
+
* タベースの場合は例外が発生する。
|
155
|
+
* @option options :key_normalize
|
156
|
+
* +true+ を指定するとキーを正規化する。
|
157
|
+
* @option options :key_type
|
158
|
+
* キーの種類を示すオブジェクトを指定する。キーの種類には型
|
159
|
+
* 名("Int32"や"ShortText"など)またはGroonga::Typeまたは
|
160
|
+
* テーブル(Groonga::Array、Groonga::Hash、
|
161
|
+
* Groonga::PatriciaTrieのどれか)を指定する。
|
162
|
+
*
|
163
|
+
* Groonga::Typeを指定した場合は、その型が示す範囲の値をキー
|
164
|
+
* として使用する。ただし、キーの最大サイズは4096バイトで
|
165
|
+
* あるため、Groonga::Type::TEXTやGroonga::Type::LONG_TEXT
|
166
|
+
* は使用できない。
|
167
|
+
*
|
168
|
+
* テーブルを指定した場合はレコードIDをキーとして使用する。
|
169
|
+
* 指定したテーブルのGroonga::Recordをキーとして使用するこ
|
170
|
+
* ともでき、その場合は自動的にGroonga::Recordからレコード
|
171
|
+
* IDを取得する。
|
172
|
+
*
|
173
|
+
* 省略した場合はShortText型をキーとして使用する。この場合、
|
174
|
+
* 4096バイトまで使用可能である。
|
175
|
+
* @option options :value_type
|
176
|
+
* 値の型を指定する。省略すると値のための領域を確保しない。
|
177
|
+
* 値を保存したい場合は必ず指定すること。
|
178
|
+
*
|
179
|
+
* 参考: Groonga::Type.new
|
180
|
+
* @option options [Groonga::IndexColumn] :default_tokenizer
|
181
|
+
* Groonga::IndexColumnで使用するトークナイザを指定する。
|
182
|
+
* デフォルトでは何も設定されていないので、テーブルに
|
183
|
+
* Groonga::IndexColumnを定義する場合は
|
184
|
+
* <tt>"TokenBigram"</tt>などを指定する必要がある。
|
185
|
+
* @option options [Groonga::Record#n_sub_records] :sub_records
|
186
|
+
* +true+ を指定すると#groupでグループ化したときに、
|
187
|
+
* Groonga::Record#n_sub_recordsでグループに含まれるレコー
|
188
|
+
* ドの件数を取得できる。
|
147
189
|
*/
|
148
190
|
static VALUE
|
149
191
|
rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
|
@@ -220,9 +262,6 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
|
|
220
262
|
}
|
221
263
|
|
222
264
|
/*
|
223
|
-
* call-seq:
|
224
|
-
* hash.search(key, options=nil) -> Groonga::Hash
|
225
|
-
*
|
226
265
|
* _key_ にマッチするレコードのIDがキーに入っている
|
227
266
|
* Groonga::Hashを返す。マッチするレコードがない場合は空の
|
228
267
|
* Groonga::Hashが返る。
|
@@ -231,14 +270,6 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
|
|
231
270
|
* チしたレコードIDがキーのレコードを追加することができる。
|
232
271
|
* +:result+ にテーブルを指定した場合は、そのテーブルが返る。
|
233
272
|
*
|
234
|
-
* _options_ に指定可能な値は以下の通り。
|
235
|
-
* @param [::Hash] options The name and value
|
236
|
-
* pairs. Omitted names are initialized as the default value
|
237
|
-
*
|
238
|
-
* @option options :result The result
|
239
|
-
*
|
240
|
-
* 結果を格納するテーブル。
|
241
|
-
*
|
242
273
|
* @example 複数のキーで検索し、結果を1つのテーブルに集める。
|
243
274
|
* result = nil
|
244
275
|
* keys = ["morita", "gunyara-kun", "yu"]
|
@@ -249,6 +280,13 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass)
|
|
249
280
|
* user = record.key
|
250
281
|
* p user.key # -> "morita"または"gunyara-kun"または"yu"
|
251
282
|
* end
|
283
|
+
*
|
284
|
+
* @overload search(key, options=nil)
|
285
|
+
* @param [::Hash] options The name and value
|
286
|
+
* pairs. Omitted names are initialized as the default value
|
287
|
+
* @option options :result
|
288
|
+
* 結果を格納するテーブル。
|
289
|
+
* @return [Groonga::Hash]
|
252
290
|
*/
|
253
291
|
static VALUE
|
254
292
|
rb_grn_hash_search (int argc, VALUE *argv, VALUE self)
|