rroonga 5.0.9 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  # Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
2
3
  #
3
4
  # This library is free software; you can redistribute it and/or
4
5
  # modify it under the terms of the GNU Lesser General Public
@@ -237,6 +238,46 @@ class DatabaseTest < Test::Unit::TestCase
237
238
  @database.plugin_paths)
238
239
  end
239
240
 
241
+ def test_reindex
242
+ setup_database
243
+ Groonga::Schema.define do |schema|
244
+ schema.create_table("Memos",
245
+ :type => :array) do |table|
246
+ table.column("content", "Text")
247
+ end
248
+ schema.create_table("Terms",
249
+ :type => :patricia_trie,
250
+ :key_type => "ShortText",
251
+ :default_tokenizer => "TokenBigram",
252
+ :normalizer => "NormalizerAuto") do |table|
253
+ table.index("Memos.content")
254
+ end
255
+ end
256
+
257
+ memos = context["Memos"]
258
+ memos.add(:content => "This is a memo")
259
+
260
+ terms = context["Terms"]
261
+ terms.delete("this")
262
+
263
+ assert_equal([
264
+ "a",
265
+ "is",
266
+ "memo",
267
+ ],
268
+ terms.collect(&:_key).sort)
269
+
270
+ @database.reindex
271
+
272
+ assert_equal([
273
+ "a",
274
+ "is",
275
+ "memo",
276
+ "this",
277
+ ],
278
+ terms.collect(&:_key).sort)
279
+ end
280
+
240
281
  class RemoveTest < self
241
282
  setup :setup_database
242
283
 
@@ -1,4 +1,5 @@
1
1
  # Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
2
3
  #
3
4
  # This library is free software; you can redistribute it and/or
4
5
  # modify it under the terms of the GNU Lesser General Public
@@ -20,6 +21,89 @@ class FixSizeColumnTest < Test::Unit::TestCase
20
21
  setup_database
21
22
  end
22
23
 
24
+ def test_reindex
25
+ Groonga::Schema.define do |schema|
26
+ schema.create_table("Users", :type => :hash) do |table|
27
+ table.integer32("age")
28
+ table.integer32("score")
29
+ end
30
+
31
+ schema.create_table("Numbers",
32
+ :type => :patricia_trie,
33
+ :key_type => :integer32) do |table|
34
+ table.index("Users.age")
35
+ table.index("Users.score")
36
+ end
37
+
38
+ schema.create_table("Ages",
39
+ :type => :patricia_trie,
40
+ :key_type => :integer32) do |table|
41
+ table.index("Users.age")
42
+ end
43
+
44
+ schema.create_table("Scores",
45
+ :type => :patricia_trie,
46
+ :key_type => :integer32) do |table|
47
+ table.index("Users.score")
48
+ end
49
+ end
50
+
51
+ users = context["Users"]
52
+ users.add("Alice", :age => 16, :score => 123)
53
+ users.add("Bob", :age => 29, :score => -10)
54
+
55
+ numbers = context["Numbers"]
56
+ numbers.delete(16)
57
+ numbers.delete(123)
58
+
59
+ ages = context["Ages"]
60
+ ages.delete(29)
61
+
62
+ scores = context["Scores"]
63
+ scores.delete(-10)
64
+
65
+ assert_equal({
66
+ :numbers => [
67
+ -10,
68
+ 29,
69
+ ],
70
+ :ages => [
71
+ 16,
72
+ ],
73
+ :scores => [
74
+ 123,
75
+ ],
76
+ },
77
+ {
78
+ :numbers => numbers.collect(&:_key).sort,
79
+ :ages => ages.collect(&:_key).sort,
80
+ :scores => scores.collect(&:_key).sort,
81
+ })
82
+
83
+ context["Users.age"].reindex
84
+
85
+ assert_equal({
86
+ :numbers => [
87
+ -10,
88
+ 16,
89
+ 29,
90
+ ],
91
+ :ages => [
92
+ 16,
93
+ 29,
94
+ ],
95
+ :scores => [
96
+ 123,
97
+ ],
98
+ },
99
+ {
100
+ :numbers => numbers.collect(&:_key).sort,
101
+ :ages => ages.collect(&:_key).sort,
102
+ :scores => scores.collect(&:_key).sort,
103
+ })
104
+
105
+ end
106
+
23
107
  class OperationTest < self
24
108
  def setup
25
109
  super
@@ -1,6 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  # Copyright (C) 2009-2015 Kouhei Sutou <kou@clear-code.com>
4
+ # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
4
5
  #
5
6
  # This library is free software; you can redistribute it and/or
6
7
  # modify it under the terms of the GNU Lesser General Public
@@ -175,6 +176,75 @@ class IndexColumnTest < Test::Unit::TestCase
175
176
  end
176
177
  end
177
178
 
179
+ def test_reindex
180
+ Groonga::Schema.define do |schema|
181
+ schema.create_table("Memos", :type => :array) do |table|
182
+ table.short_text("title")
183
+ table.text("content")
184
+ end
185
+
186
+ schema.create_table("BigramTerms",
187
+ :type => :patricia_trie,
188
+ :key_type => :short_text,
189
+ :normalizer => "NormalizerAuto",
190
+ :default_tokenizer => "TokenBigram") do |table|
191
+ table.index("Memos.title")
192
+ table.index("Memos.content")
193
+ end
194
+
195
+ schema.create_table("MeCabTerms",
196
+ :type => :patricia_trie,
197
+ :key_type => :short_text,
198
+ :normalizer => "NormalizerAuto",
199
+ :default_tokenizer => "TokenMecab") do |table|
200
+ table.index("Memos.title")
201
+ table.index("Memos.content")
202
+ end
203
+ end
204
+
205
+ memos = context["Memos"]
206
+ memos.add(:title => "memo1", :content => "もり")
207
+
208
+ bigram_terms = context["BigramTerms"]
209
+ bigram_terms.delete("memo")
210
+ bigram_terms.delete("り")
211
+
212
+ mecab_terms = context["MeCabTerms"]
213
+ mecab_terms.delete("1")
214
+ mecab_terms.delete("もり")
215
+
216
+ assert_equal({
217
+ :bigram => [
218
+ "1",
219
+ "もり",
220
+ ],
221
+ :mecab => [
222
+ "memo",
223
+ ],
224
+ },
225
+ {
226
+ :bigram => bigram_terms.collect(&:_key).sort,
227
+ :mecab => mecab_terms.collect(&:_key).sort,
228
+ })
229
+
230
+ context["MeCabTerms.Memos_content"].reindex
231
+
232
+ assert_equal({
233
+ :bigram => [
234
+ "1",
235
+ "もり",
236
+ ],
237
+ :mecab => [
238
+ "memo",
239
+ "もり",
240
+ ],
241
+ },
242
+ {
243
+ :bigram => bigram_terms.collect(&:_key).sort,
244
+ :mecab => mecab_terms.collect(&:_key).sort,
245
+ })
246
+ end
247
+
178
248
  class NGramTest < self
179
249
  setup
180
250
  def setup_schema
@@ -575,7 +645,7 @@ class IndexColumnTest < Test::Unit::TestCase
575
645
  end
576
646
 
577
647
  def test_query
578
- assert_equal(6, @index.estimate_size("roonga"))
648
+ assert_equal(3, @index.estimate_size("roonga"))
579
649
  end
580
650
  end
581
651
 
@@ -0,0 +1,20 @@
1
+ # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
+
16
+ class PackageLabelTest < Test::Unit::TestCase
17
+ def test_reader
18
+ assert_equal("Groonga", Groonga.package_label)
19
+ end
20
+ end
@@ -1,4 +1,5 @@
1
1
  # Copyright (C) 2013-2014 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
2
3
  #
3
4
  # This library is free software; you can redistribute it and/or
4
5
  # modify it under the terms of the GNU Lesser General Public
@@ -195,4 +196,45 @@ class TableKeySupportTest < Test::Unit::TestCase
195
196
  end
196
197
  end
197
198
  end
199
+
200
+ class ReindexTest < self
201
+ def test_patricia_trie
202
+ Groonga::Schema.define do |schema|
203
+ schema.create_table("Memos",
204
+ :type => :array) do |table|
205
+ table.text("content")
206
+ end
207
+ schema.create_table("Terms",
208
+ :type => :patricia_trie,
209
+ :key_type => :short_text,
210
+ :default_tokenizer => "TokenBigram",
211
+ :normalizer => "NormalizerAuto") do |table|
212
+ table.index("Memos.content")
213
+ end
214
+ end
215
+
216
+ memos = context["Memos"]
217
+ memos.add(:content => "This is a memo")
218
+
219
+ terms = context["Terms"]
220
+ terms.delete("this")
221
+
222
+ assert_equal([
223
+ "a",
224
+ "is",
225
+ "memo",
226
+ ],
227
+ terms.collect(&:_key).sort)
228
+
229
+ terms.reindex
230
+
231
+ assert_equal([
232
+ "a",
233
+ "is",
234
+ "memo",
235
+ "this",
236
+ ],
237
+ terms.collect(&:_key).sort)
238
+ end
239
+ end
198
240
  end
@@ -1,4 +1,5 @@
1
1
  # Copyright (C) 2009-2013 Kouhei Sutou <kou@clear-code.com>
2
+ # Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
2
3
  #
3
4
  # This library is free software; you can redistribute it and/or
4
5
  # modify it under the terms of the GNU Lesser General Public
@@ -455,6 +456,18 @@ class TableTest < Test::Unit::TestCase
455
456
  ],
456
457
  results.collect(&:location))
457
458
  end
459
+
460
+ test "accessor" do
461
+ searched_posts = @posts.select("true", :syntax => :script)
462
+ results = searched_posts.geo_sort(searched_posts.column("location"),
463
+ "35.7119x139.7983")
464
+ assert_equal([
465
+ Groonga::WGS84GeoPoint.new("35.730061x139.796234"),
466
+ Groonga::WGS84GeoPoint.new("35.685341x139.783981"),
467
+ Groonga::WGS84GeoPoint.new("35.720253x139.762573"),
468
+ ],
469
+ results.collect(&:location))
470
+ end
458
471
  end
459
472
 
460
473
  def test_union!
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
2
- # Copyright (C) 2014 Masafumi Yokoyama <myokoym@gmail.com>
2
+ # Copyright (C) 2014-2016 Masafumi Yokoyama <yokoyama@clear-code.com>
3
3
  #
4
4
  # This library is free software; you can redistribute it and/or
5
5
  # modify it under the terms of the GNU Lesser General Public
@@ -124,6 +124,76 @@ class VariableSizeColumnTest < Test::Unit::TestCase
124
124
  assert_equal(1, @name.defrag)
125
125
  end
126
126
 
127
+ def test_reindex
128
+ Groonga::Schema.define do |schema|
129
+ schema.create_table("Memos", :type => :array) do |table|
130
+ table.short_text("title")
131
+ table.text("content")
132
+ end
133
+
134
+ schema.create_table("BigramTerms",
135
+ :type => :patricia_trie,
136
+ :key_type => :short_text,
137
+ :normalizer => "NormalizerAuto",
138
+ :default_tokenizer => "TokenBigram") do |table|
139
+ table.index("Memos.title")
140
+ table.index("Memos.content")
141
+ end
142
+
143
+ schema.create_table("MeCabTerms",
144
+ :type => :patricia_trie,
145
+ :key_type => :short_text,
146
+ :normalizer => "NormalizerAuto",
147
+ :default_tokenizer => "TokenMecab") do |table|
148
+ table.index("Memos.title")
149
+ table.index("Memos.content")
150
+ end
151
+ end
152
+
153
+ memos = context["Memos"]
154
+ memos.add(:title => "memo1", :content => "もり")
155
+
156
+ bigram_terms = context["BigramTerms"]
157
+ bigram_terms.delete("memo")
158
+ bigram_terms.delete("り")
159
+
160
+ mecab_terms = context["MeCabTerms"]
161
+ mecab_terms.delete("1")
162
+ mecab_terms.delete("もり")
163
+
164
+ assert_equal({
165
+ :bigram => [
166
+ "1",
167
+ "もり",
168
+ ],
169
+ :mecab => [
170
+ "memo",
171
+ ],
172
+ },
173
+ {
174
+ :bigram => bigram_terms.collect(&:_key).sort,
175
+ :mecab => mecab_terms.collect(&:_key).sort,
176
+ })
177
+
178
+ context["Memos.content"].reindex
179
+
180
+ assert_equal({
181
+ :bigram => [
182
+ "1",
183
+ "もり",
184
+ "り",
185
+ ],
186
+ :mecab => [
187
+ "memo",
188
+ "もり",
189
+ ],
190
+ },
191
+ {
192
+ :bigram => bigram_terms.collect(&:_key).sort,
193
+ :mecab => mecab_terms.collect(&:_key).sort,
194
+ })
195
+ end
196
+
127
197
  class VectorTest < self
128
198
  class ReferenceTest < self
129
199
  def test_append
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: 5.0.9
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-11-10 00:00:00.000000000 Z
15
+ date: 2016-01-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pkg-config
@@ -209,8 +209,8 @@ email:
209
209
  - dara@shidara.net
210
210
  executables:
211
211
  - grntest-log-analyze
212
- - grndump
213
212
  - groonga-database-inspect
213
+ - grndump
214
214
  - groonga-index-dump
215
215
  extensions:
216
216
  - ext/groonga/extconf.rb
@@ -244,7 +244,7 @@ files:
244
244
  - ext/groonga/rb-grn-array-cursor.c
245
245
  - ext/groonga/rb-grn-array.c
246
246
  - ext/groonga/rb-grn-column.c
247
- - ext/groonga/rb-grn-conf.c
247
+ - ext/groonga/rb-grn-config.c
248
248
  - ext/groonga/rb-grn-context.c
249
249
  - ext/groonga/rb-grn-database.c
250
250
  - ext/groonga/rb-grn-double-array-trie-cursor.c
@@ -328,7 +328,7 @@ files:
328
328
  - test/test-array.rb
329
329
  - test/test-column.rb
330
330
  - test/test-command-select.rb
331
- - test/test-conf.rb
331
+ - test/test-config.rb
332
332
  - test/test-context.rb
333
333
  - test/test-convert.rb
334
334
  - test/test-database-dumper.rb
@@ -351,6 +351,7 @@ files:
351
351
  - test/test-memory-pool.rb
352
352
  - test/test-normalizer.rb
353
353
  - test/test-operator.rb
354
+ - test/test-package-label.rb
354
355
  - test/test-pagination.rb
355
356
  - test/test-patricia-trie.rb
356
357
  - test/test-plugin.rb
@@ -404,71 +405,72 @@ required_rubygems_version: !ruby/object:Gem::Requirement
404
405
  version: '0'
405
406
  requirements: []
406
407
  rubyforge_project:
407
- rubygems_version: 2.2.2
408
+ rubygems_version: 2.4.5.1
408
409
  signing_key:
409
410
  specification_version: 4
410
411
  summary: Ruby bindings for Groonga that provide full text search and column store
411
412
  features.
412
413
  test_files:
413
- - test/test-schema-create-table.rb
414
- - test/test-type.rb
415
- - test/test-table-select.rb
416
- - test/test-variable-size-column.rb
414
+ - test/test-context.rb
415
+ - test/test-normalizer.rb
416
+ - test/test-double-array-trie.rb
417
417
  - test/test-token-regexp.rb
418
+ - test/test-remote.rb
419
+ - test/test-expression.rb
420
+ - test/test-schema-dumper.rb
421
+ - test/test-patricia-trie.rb
422
+ - test/test-table-group.rb
423
+ - test/test-table-select.rb
424
+ - test/test-encoding.rb
418
425
  - test/test-windows-event-logger.rb
419
- - test/test-table-select-normalize.rb
420
- - test/test-lock-timeout.rb
421
- - test/test-conf.rb
422
- - test/test-record.rb
423
426
  - test/test-plugin.rb
427
+ - test/test-table-select-normalize.rb
428
+ - test/test-hash.rb
429
+ - test/test-gqtp.rb
430
+ - test/test-table-dumper.rb
431
+ - test/test-pagination.rb
432
+ - test/test-column.rb
433
+ - test/test-table-traverse.rb
434
+ - test/test-type.rb
435
+ - test/test-package-label.rb
424
436
  - test/groonga-test-utils.rb
425
- - test/test-logger.rb
437
+ - test/test-thread.rb
438
+ - test/test-procedure.rb
439
+ - test/test-query-logger.rb
440
+ - test/test-index-column.rb
441
+ - test/test-vector-column.rb
442
+ - test/test-fix-size-column.rb
426
443
  - test/test-operator.rb
427
- - test/test-snippet.rb
428
- - test/test-memory-pool.rb
429
- - test/test-command-select.rb
430
- - test/test-expression-builder.rb
431
444
  - test/test-database-dumper.rb
432
- - test/test-encoding.rb
433
- - test/test-variable.rb
434
- - test/test-context.rb
435
445
  - test/run-test.rb
436
- - test/test-thread.rb
437
446
  - test/test-index-cursor.rb
447
+ - test/test-schema-type.rb
448
+ - test/test-database.rb
449
+ - test/test-logger.rb
450
+ - test/test-table.rb
451
+ - test/test-record.rb
452
+ - test/test-version.rb
438
453
  - test/test-table-select-mecab.rb
439
- - test/test-double-array-trie.rb
440
- - test/test-sub-records.rb
441
- - test/test-table-offset-and-limit.rb
454
+ - test/test-lock-timeout.rb
442
455
  - test/test-table-select-weight.rb
456
+ - test/test-geo-point.rb
457
+ - test/test-array.rb
458
+ - test/test-sub-records.rb
459
+ - test/test-schema-create-table.rb
460
+ - test/test-schema.rb
461
+ - test/test-command-select.rb
462
+ - test/test-expression-builder.rb
443
463
  - test/test-convert.rb
464
+ - test/test-memory-pool.rb
444
465
  - test/test-flushable.rb
445
- - test/test-column.rb
446
- - test/test-table.rb
447
- - test/test-gqtp.rb
448
- - test/test-query-logger.rb
449
- - test/test-table-traverse.rb
450
- - test/test-schema.rb
451
- - test/test-version.rb
466
+ - test/test-table-offset-and-limit.rb
452
467
  - test/test-exception.rb
453
- - test/test-array.rb
454
- - test/test-patricia-trie.rb
455
- - test/test-schema-type.rb
456
- - test/test-database.rb
457
- - test/test-index-column.rb
458
- - test/test-normalizer.rb
459
- - test/test-vector-column.rb
460
- - test/test-database-inspector.rb
461
- - test/test-pagination.rb
462
- - test/test-procedure.rb
463
- - test/test-geo-point.rb
464
- - test/test-table-group.rb
468
+ - test/test-variable-size-column.rb
469
+ - test/test-config.rb
465
470
  - test/test-table-key-support.rb
471
+ - test/test-database-inspector.rb
472
+ - test/test-variable.rb
466
473
  - test/test-statistic-measurer.rb
467
- - test/test-fix-size-column.rb
474
+ - test/test-snippet.rb
468
475
  - test/test-accessor.rb
469
- - test/test-hash.rb
470
- - test/test-expression.rb
471
- - test/test-remote.rb
472
- - test/test-schema-dumper.rb
473
- - test/test-table-dumper.rb
474
476
  has_rdoc: