rroonga 2.0.5 → 2.0.6
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 +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
data/test/test-command-select.rb
CHANGED
@@ -17,7 +17,9 @@ class CommandSelectTest < Test::Unit::TestCase
|
|
17
17
|
include GroongaTestUtils
|
18
18
|
|
19
19
|
setup :setup_database
|
20
|
-
setup
|
20
|
+
setup :setup_tables
|
21
|
+
setup :setup_data
|
22
|
+
|
21
23
|
def setup_data
|
22
24
|
Groonga::Schema.define do |schema|
|
23
25
|
schema.create_table("Books",
|
@@ -136,6 +138,68 @@ class CommandSelectTest < Test::Unit::TestCase
|
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
141
|
+
class QueryFlagsTest < self
|
142
|
+
def setup_tables
|
143
|
+
Groonga::Schema.define do |schema|
|
144
|
+
schema.create_table("Entries",
|
145
|
+
:type => :hash,
|
146
|
+
:key_type => "ShortText") do |table|
|
147
|
+
table.text("content")
|
148
|
+
end
|
149
|
+
|
150
|
+
schema.create_table("Terms",
|
151
|
+
:type => :patricia_trie,
|
152
|
+
:default_tokenizer => "TokenBigram",
|
153
|
+
:key_type => "ShortText",
|
154
|
+
:key_normalize => true) do |table|
|
155
|
+
table.index("Entries.content",
|
156
|
+
:name => "entries_content_index", :with_position => true)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
@entries = Groonga["Entries"]
|
161
|
+
end
|
162
|
+
|
163
|
+
class TestAllowLeadingNot < self
|
164
|
+
def setup_data
|
165
|
+
@first_post =
|
166
|
+
@entries.add("The first post!",
|
167
|
+
"content" => "Welcome! This is my first post!")
|
168
|
+
@groonga =
|
169
|
+
@entries.add("Groonga",
|
170
|
+
"content" => "I started to use groonga. It's very fast!")
|
171
|
+
@mroonga =
|
172
|
+
@entries.add("Mroonga",
|
173
|
+
"content" => "I also started to use mroonga. " +
|
174
|
+
"It's also very fast! Really fast!")
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_true
|
178
|
+
result = @entries.select do |record|
|
179
|
+
record[:content].match("-mroonga", :allow_leading_not => true)
|
180
|
+
end
|
181
|
+
assert_equal_select_result([@first_post, @groonga],
|
182
|
+
result)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_false
|
186
|
+
assert_raise(Groonga::SyntaxError) do
|
187
|
+
@entries.select do |record|
|
188
|
+
record[:content].match("-mroonga", :allow_leading_not => false)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_default
|
194
|
+
assert_raise(Groonga::SyntaxError) do
|
195
|
+
@entries.select do |record|
|
196
|
+
record[:content].match("-mroonga")
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
139
203
|
private
|
140
204
|
def normalize_drill_down(drill_down)
|
141
205
|
normalized_drill_down = {}
|
@@ -178,4 +242,5 @@ class CommandSelectTest < Test::Unit::TestCase
|
|
178
242
|
result.records)
|
179
243
|
end
|
180
244
|
end
|
245
|
+
|
181
246
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2011 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -66,6 +66,16 @@ class DatabaseDumperTest < Test::Unit::TestCase
|
|
66
66
|
|
67
67
|
def dumped_schema
|
68
68
|
<<-EOS
|
69
|
+
#{dumped_schema_tables}
|
70
|
+
|
71
|
+
#{dumped_schema_reference_columns}
|
72
|
+
|
73
|
+
#{dumped_schema_index_columns}
|
74
|
+
EOS
|
75
|
+
end
|
76
|
+
|
77
|
+
def dumped_schema_tables
|
78
|
+
<<-EOS.chomp
|
69
79
|
table_create Posts TABLE_NO_KEY
|
70
80
|
column_create Posts created_at COLUMN_SCALAR Time
|
71
81
|
column_create Posts n_goods COLUMN_SCALAR UInt32
|
@@ -79,10 +89,18 @@ column_create Tags name COLUMN_SCALAR Text
|
|
79
89
|
|
80
90
|
table_create Users TABLE_HASH_KEY --key_type ShortText
|
81
91
|
column_create Users name COLUMN_SCALAR Text
|
92
|
+
EOS
|
93
|
+
end
|
82
94
|
|
95
|
+
def dumped_schema_reference_columns
|
96
|
+
<<-EOS.chomp
|
83
97
|
column_create Posts author COLUMN_SCALAR Users
|
84
98
|
column_create Posts tags COLUMN_VECTOR Tags
|
99
|
+
EOS
|
100
|
+
end
|
85
101
|
|
102
|
+
def dumped_schema_index_columns
|
103
|
+
<<-EOS.chomp
|
86
104
|
column_create Tags Posts_tag_text COLUMN_INDEX Posts tag_text
|
87
105
|
|
88
106
|
column_create Users Posts_author COLUMN_INDEX Posts author
|
@@ -110,7 +128,9 @@ EOS
|
|
110
128
|
|
111
129
|
def test_default
|
112
130
|
assert_equal(<<-EOS, dump)
|
113
|
-
#{
|
131
|
+
#{dumped_schema_tables}
|
132
|
+
|
133
|
+
#{dumped_schema_reference_columns}
|
114
134
|
|
115
135
|
load --table Posts
|
116
136
|
[
|
@@ -130,30 +150,40 @@ load --table Users
|
|
130
150
|
["_key","name"],
|
131
151
|
["mori",""]
|
132
152
|
]
|
153
|
+
|
154
|
+
#{dumped_schema_index_columns}
|
133
155
|
EOS
|
134
156
|
end
|
135
157
|
|
136
158
|
def test_limit_tables
|
137
159
|
assert_equal(<<-EOS, dump(:tables => ["Posts"]))
|
138
|
-
#{
|
160
|
+
#{dumped_schema_tables}
|
161
|
+
|
162
|
+
#{dumped_schema_reference_columns}
|
139
163
|
|
140
164
|
load --table Posts
|
141
165
|
[
|
142
166
|
["_id","author","created_at","n_goods","published","rank","tag_text","tags","title"],
|
143
167
|
[1,"mori",1268034720.0,4,true,10,"search mori",["search","mori"],"Why search engine find?"]
|
144
168
|
]
|
169
|
+
|
170
|
+
#{dumped_schema_index_columns}
|
145
171
|
EOS
|
146
172
|
end
|
147
173
|
|
148
174
|
def test_limit_tables_with_regexp
|
149
175
|
assert_equal(<<-EOS, dump(:tables => [/Posts?/]))
|
150
|
-
#{
|
176
|
+
#{dumped_schema_tables}
|
177
|
+
|
178
|
+
#{dumped_schema_reference_columns}
|
151
179
|
|
152
180
|
load --table Posts
|
153
181
|
[
|
154
182
|
["_id","author","created_at","n_goods","published","rank","tag_text","tags","title"],
|
155
183
|
[1,"mori",1268034720.0,4,true,10,"search mori",["search","mori"],"Why search engine find?"]
|
156
184
|
]
|
185
|
+
|
186
|
+
#{dumped_schema_index_columns}
|
157
187
|
EOS
|
158
188
|
end
|
159
189
|
|
@@ -162,7 +192,9 @@ EOS
|
|
162
192
|
:exclude_tables => ["Posts"],
|
163
193
|
}
|
164
194
|
assert_equal(<<-EOS, dump(dump_options))
|
165
|
-
#{
|
195
|
+
#{dumped_schema_tables}
|
196
|
+
|
197
|
+
#{dumped_schema_reference_columns}
|
166
198
|
|
167
199
|
load --table Tags
|
168
200
|
[
|
@@ -176,6 +208,8 @@ load --table Users
|
|
176
208
|
["_key","name"],
|
177
209
|
["mori",""]
|
178
210
|
]
|
211
|
+
|
212
|
+
#{dumped_schema_index_columns}
|
179
213
|
EOS
|
180
214
|
end
|
181
215
|
|
@@ -184,7 +218,9 @@ EOS
|
|
184
218
|
:exclude_tables => [/Posts?/],
|
185
219
|
}
|
186
220
|
assert_equal(<<-EOS, dump(dump_options))
|
187
|
-
#{
|
221
|
+
#{dumped_schema_tables}
|
222
|
+
|
223
|
+
#{dumped_schema_reference_columns}
|
188
224
|
|
189
225
|
load --table Tags
|
190
226
|
[
|
@@ -198,6 +234,8 @@ load --table Users
|
|
198
234
|
["_key","name"],
|
199
235
|
["mori",""]
|
200
236
|
]
|
237
|
+
|
238
|
+
#{dumped_schema_index_columns}
|
201
239
|
EOS
|
202
240
|
end
|
203
241
|
|
@@ -207,13 +245,17 @@ EOS
|
|
207
245
|
:tables => ["Posts", "Users"],
|
208
246
|
}
|
209
247
|
assert_equal(<<-EOS, dump(dump_options))
|
210
|
-
#{
|
248
|
+
#{dumped_schema_tables}
|
249
|
+
|
250
|
+
#{dumped_schema_reference_columns}
|
211
251
|
|
212
252
|
load --table Users
|
213
253
|
[
|
214
254
|
["_key","name"],
|
215
255
|
["mori",""]
|
216
256
|
]
|
257
|
+
|
258
|
+
#{dumped_schema_index_columns}
|
217
259
|
EOS
|
218
260
|
end
|
219
261
|
|
@@ -241,9 +283,7 @@ EOS
|
|
241
283
|
end
|
242
284
|
|
243
285
|
def test_no_tables
|
244
|
-
assert_equal(
|
245
|
-
#{dumped_schema.chomp}
|
246
|
-
EOS
|
286
|
+
assert_equal(dumped_schema, dump(:dump_tables => false))
|
247
287
|
end
|
248
288
|
end
|
249
289
|
|
@@ -398,6 +398,47 @@ EOC
|
|
398
398
|
end
|
399
399
|
end
|
400
400
|
|
401
|
+
class TermExtractTest < self
|
402
|
+
def setup_tables
|
403
|
+
Groonga::Schema.define do |schema|
|
404
|
+
schema.create_table("Words",
|
405
|
+
:type => :patricia_trie,
|
406
|
+
:key_type => "ShortText",
|
407
|
+
:default_tokenizer => "TokenBigram",
|
408
|
+
:key_normalize => true) do |table|
|
409
|
+
table.text("content")
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
@words = Groonga["Words"]
|
414
|
+
end
|
415
|
+
|
416
|
+
def setup_data
|
417
|
+
@words.add("groonga")
|
418
|
+
@words.add("mroonga")
|
419
|
+
@words.add("Senna")
|
420
|
+
@words.add("Tritonn")
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_table
|
424
|
+
result = @words.select do |record|
|
425
|
+
record.key.term_extract("Groonga is the successor project to Senna.")
|
426
|
+
end
|
427
|
+
assert_equal(["groonga", "senna"].sort,
|
428
|
+
result.collect {|record| record.key.key}.sort)
|
429
|
+
end
|
430
|
+
|
431
|
+
def test_not_key_column
|
432
|
+
message = "term extraction supports _key column only: <content>"
|
433
|
+
exception = ArgumentError.new(message)
|
434
|
+
assert_raise(exception) do
|
435
|
+
@words.select do |record|
|
436
|
+
record.content.term_extract("Groonga is the successor project to Senna.")
|
437
|
+
end
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
401
442
|
class RecordTest < self
|
402
443
|
def setup_tables
|
403
444
|
Groonga::Schema.define do |schema|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rroonga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pkg-config
|
@@ -349,7 +349,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
349
349
|
version: '0'
|
350
350
|
segments:
|
351
351
|
- 0
|
352
|
-
hash: -
|
352
|
+
hash: -4521341651743360062
|
353
353
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
354
354
|
none: false
|
355
355
|
requirements:
|
@@ -358,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
358
|
version: '0'
|
359
359
|
segments:
|
360
360
|
- 0
|
361
|
-
hash: -
|
361
|
+
hash: -4521341651743360062
|
362
362
|
requirements: []
|
363
363
|
rubyforge_project: groonga
|
364
364
|
rubygems_version: 1.8.23
|