rroonga 6.1.3 → 7.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,17 +16,17 @@
16
16
 
17
17
  module RroongaBuild
18
18
  module RequiredGroongaVersion
19
- MAJOR = 6
20
- MINOR = 1
21
- MICRO = 1
19
+ MAJOR = 7
20
+ MINOR = 0
21
+ MICRO = 2
22
22
  VERSION = [MAJOR, MINOR, MICRO]
23
- RELEASED_DATE = Time.utc(2016, 11, 29)
23
+ RELEASED_DATE = Time.utc(2017, 4, 29)
24
24
  end
25
25
 
26
26
  module LatestGroongaVersion
27
- MAJOR = 6
28
- MINOR = 1
29
- MICRO = 3
27
+ MAJOR = 7
28
+ MINOR = 0
29
+ MICRO = 2
30
30
  VERSION = [MAJOR, MINOR, MICRO]
31
31
  end
32
32
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2016-2017 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
@@ -21,7 +21,7 @@ class DataColumnTest < Test::Unit::TestCase
21
21
  end
22
22
 
23
23
  sub_test_case "#apply_window_function" do
24
- def test_no_argument
24
+ def test_sort_keys
25
25
  Groonga::Schema.define do |schema|
26
26
  schema.create_table("Comments") do |table|
27
27
  table.uint32("nth")
@@ -49,5 +49,74 @@ class DataColumnTest < Test::Unit::TestCase
49
49
  ],
50
50
  comments.collect {|comment| [comment.id, comment.nth]})
51
51
  end
52
+
53
+ def test_group_keys
54
+ Groonga::Schema.define do |schema|
55
+ schema.create_table("Comments") do |table|
56
+ table.uint32("nth")
57
+ table.short_text("category")
58
+ end
59
+ end
60
+ comments = Groonga["Comments"]
61
+ nth = Groonga["Comments.nth"]
62
+
63
+ 3.times do
64
+ comments.add(:category => "a")
65
+ end
66
+ 3.times do
67
+ comments.add(:category => "b")
68
+ end
69
+
70
+ options = {
71
+ :sort_keys => [["_id", "desc"]],
72
+ :group_keys => ["category"],
73
+ }
74
+ nth.apply_window_function(options) do |record|
75
+ record.call("record_number")
76
+ end
77
+ values = comments.collect do |comment|
78
+ [
79
+ comment.id,
80
+ comment.nth,
81
+ comment.category,
82
+ ]
83
+ end
84
+ assert_equal([
85
+ [1, 3, "a"],
86
+ [2, 2, "a"],
87
+ [3, 1, "a"],
88
+ [4, 3, "b"],
89
+ [5, 2, "b"],
90
+ [6, 1, "b"],
91
+ ],
92
+ values)
93
+ end
94
+ end
95
+
96
+ sub_test_case "#apply_expression" do
97
+ def test_simple
98
+ Groonga::Schema.define do |schema|
99
+ schema.create_table("Comments") do |table|
100
+ table.uint32("base")
101
+ table.uint32("plus1")
102
+ end
103
+ end
104
+ comments = Groonga["Comments"]
105
+ plus1 = Groonga["Comments.plus1"]
106
+
107
+ 3.times do |i|
108
+ comments.add(:base => i)
109
+ end
110
+
111
+ plus1.apply_expression do |record|
112
+ record.base + 1
113
+ end
114
+ assert_equal([
115
+ [0, 1],
116
+ [1, 2],
117
+ [2, 3],
118
+ ],
119
+ comments.collect {|comment| [comment.base, comment.plus1]})
120
+ end
52
121
  end
53
122
  end
@@ -0,0 +1,43 @@
1
+ # Copyright (C) 2017 Kouhei Sutou <kou@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 DefaultCacheTest < Test::Unit::TestCase
17
+ include GroongaTestUtils
18
+
19
+ setup :setup_database
20
+ def setup
21
+ begin
22
+ yield
23
+ ensure
24
+ Groonga::DefaultCache.base_path = nil
25
+ Groonga::DefaultCache.reopen
26
+ end
27
+ end
28
+
29
+ test "set base_path" do
30
+ base_path = "#{@database_path}.cache"
31
+ keys_path = "#{base_path}.keys"
32
+ Groonga::DefaultCache.base_path = base_path
33
+ assert do
34
+ not File.exist?(keys_path)
35
+ end
36
+
37
+ Groonga::DefaultCache.reopen
38
+
39
+ assert do
40
+ File.exist?(keys_path)
41
+ end
42
+ end
43
+ end
@@ -123,6 +123,13 @@ class DoubleArrayTrieTest < Test::Unit::TestCase
123
123
  assert_true(users.has_key?("morita"))
124
124
  end
125
125
 
126
+ def test_key?
127
+ users = Groonga::DoubleArrayTrie.create(:name => "Users")
128
+ assert_false(users.key?("morita"))
129
+ users.add("morita")
130
+ assert_true(users.key?("morita"))
131
+ end
132
+
126
133
  def test_prefix_cursor
127
134
  paths = Groonga::DoubleArrayTrie.create(:name => "Paths",
128
135
  :key_type => 'ShortText')
@@ -128,10 +128,22 @@ class FixSizeColumnTest < Test::Unit::TestCase
128
128
  assert_not_predicate(@n_viewed, :vector?)
129
129
  end
130
130
 
131
+ def test_weight_vector?
132
+ assert do
133
+ not @n_viewed.weight_vector?
134
+ end
135
+ end
136
+
131
137
  def test_scalar?
132
138
  assert_predicate(@n_viewed, :scalar?)
133
139
  end
134
140
 
141
+ def test_data?
142
+ assert do
143
+ @n_viewed.data?
144
+ end
145
+ end
146
+
135
147
  def test_inspect
136
148
  assert_equal("#<Groonga::FixSizeColumn " +
137
149
  "id: <#{@n_viewed.id}>, " +
@@ -280,6 +280,13 @@ class HashTest < Test::Unit::TestCase
280
280
  index.search("engine").collect {|record| record.key.key})
281
281
  end
282
282
 
283
+ def test_key?
284
+ users = Groonga::Hash.create(:name => "Users")
285
+ assert_false(users.key?("morita"))
286
+ users.add("morita")
287
+ assert_true(users.key?("morita"))
288
+ end
289
+
283
290
  def test_has_key?
284
291
  users = Groonga::Hash.create(:name => "Users")
285
292
  assert_false(users.has_key?("morita"))
@@ -48,9 +48,21 @@ class IndexColumnTest < Test::Unit::TestCase
48
48
  assert_not_predicate(@index, :vector?)
49
49
  end
50
50
 
51
+ def test_weight_vector?
52
+ assert do
53
+ not @index.weight_vector?
54
+ end
55
+ end
56
+
51
57
  def test_scalar?
52
58
  assert_not_predicate(@index, :scalar?)
53
59
  end
60
+
61
+ def test_data?
62
+ assert do
63
+ not @index.data?
64
+ end
65
+ end
54
66
  end
55
67
 
56
68
  class CRUDTest < self
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2012-2017 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
@@ -22,20 +22,62 @@ class IndexCursorTest < Test::Unit::TestCase
22
22
  setup_records
23
23
  end
24
24
 
25
- def test_open_cursor
26
- postings = []
27
- @terms.open_cursor do |table_cursor|
28
- index_cursor = nil
29
- @content_index.open_cursor(table_cursor) do |cursor|
30
- cursor.each do |posting|
31
- postings << posting.to_hash
25
+ sub_test_case("#open_cursor") do
26
+ def test_table_cursor
27
+ postings = []
28
+ @terms.open_cursor do |table_cursor|
29
+ index_cursor = nil
30
+ @content_index.open_cursor(table_cursor) do |cursor|
31
+ cursor.each do |posting|
32
+ postings << posting.to_hash
33
+ end
34
+ index_cursor = cursor
35
+ end
36
+ assert_predicate(index_cursor, :closed?)
37
+ end
38
+
39
+ assert_equal(expected_postings(:with_position => true),
40
+ postings)
41
+ end
42
+
43
+ def test_term_id_without_position
44
+ postings = []
45
+ @terms.open_cursor do |table_cursor|
46
+ table_cursor.each do |term|
47
+ index_cursor = nil
48
+ @content_index.open_cursor(term.id,
49
+ :with_position => false) do |cursor|
50
+ cursor.each do |posting|
51
+ postings << posting.to_hash
52
+ end
53
+ index_cursor = cursor
54
+ end
55
+ assert_predicate(index_cursor, :closed?)
32
56
  end
33
- index_cursor = cursor
34
57
  end
35
- assert_predicate(index_cursor, :closed?)
58
+
59
+ assert_equal(expected_postings(:with_position => false),
60
+ postings)
36
61
  end
37
62
 
38
- assert_equal(expected_postings, postings)
63
+ def test_term_id_with_position
64
+ postings = []
65
+ @terms.open_cursor do |table_cursor|
66
+ table_cursor.each do |term|
67
+ index_cursor = nil
68
+ @content_index.open_cursor(term.id) do |cursor|
69
+ cursor.each do |posting|
70
+ postings << posting.to_hash
71
+ end
72
+ index_cursor = cursor
73
+ end
74
+ assert_predicate(index_cursor, :closed?)
75
+ end
76
+ end
77
+
78
+ assert_equal(expected_postings(:with_position => true),
79
+ postings)
80
+ end
39
81
  end
40
82
 
41
83
  def test_enumerable
@@ -45,7 +87,8 @@ class IndexCursorTest < Test::Unit::TestCase
45
87
  postings = cursor.collect do |posting|
46
88
  posting.to_hash
47
89
  end
48
- assert_equal(expected_postings, postings)
90
+ assert_equal(expected_postings(:with_position => true),
91
+ postings)
49
92
  opened = true
50
93
  end
51
94
  end
@@ -58,7 +101,8 @@ class IndexCursorTest < Test::Unit::TestCase
58
101
  @terms.open_cursor do |table_cursor|
59
102
  @content_index.open_cursor(table_cursor) do |cursor|
60
103
  postings = cursor.each.collect(&:to_hash)
61
- assert_equal(expected_postings, postings)
104
+ assert_equal(expected_postings(:with_position => true),
105
+ postings)
62
106
  opened = true
63
107
  end
64
108
  end
@@ -78,7 +122,8 @@ class IndexCursorTest < Test::Unit::TestCase
78
122
  end
79
123
  assert_equal([posting_object_ids.first] * posting_object_ids.size,
80
124
  posting_object_ids)
81
- assert_equal(expected_postings, postings)
125
+ assert_equal(expected_postings(:with_position => true),
126
+ postings)
82
127
  opened = true
83
128
  end
84
129
  end
@@ -149,20 +194,40 @@ class IndexCursorTest < Test::Unit::TestCase
149
194
  @articles.add("3", :content => "hello")
150
195
  end
151
196
 
152
- def expected_postings
153
- parameters = [:record_id, :section_id, :term_id, :position,
154
- :term_frequency, :weight, :n_rest_postings]
155
-
156
- expected = [
157
- [1, 1, 1, 0, 1, 0, 0],
158
- [2, 1, 1, 1, 1, 0, 0],
159
- [2, 1, 2, 0, 1, 0, 0],
160
- [3, 1, 2, 2, 1, 0, 0],
161
- [3, 1, 3, 0, 1, 0, 0],
162
- [3, 1, 4, 1, 1, 0, 0],
163
- [3, 1, 5, 3, 1, 0, 0],
164
- [3, 1, 6, 4, 1, 0, 0]
165
- ]
197
+ def expected_postings(options={})
198
+ parameters = [
199
+ :record_id,
200
+ :section_id,
201
+ :term_id,
202
+ :position,
203
+ :term_frequency,
204
+ :weight,
205
+ :n_rest_postings,
206
+ ]
207
+
208
+ if options[:with_position]
209
+ expected = [
210
+ [1, 1, 1, 0, 1, 0, 0],
211
+ [2, 1, 1, 1, 1, 0, 0],
212
+ [2, 1, 2, 0, 1, 0, 0],
213
+ [3, 1, 2, 2, 1, 0, 0],
214
+ [3, 1, 3, 0, 1, 0, 0],
215
+ [3, 1, 4, 1, 1, 0, 0],
216
+ [3, 1, 5, 3, 1, 0, 0],
217
+ [3, 1, 6, 4, 1, 0, 0]
218
+ ]
219
+ else
220
+ expected = [
221
+ [1, 1, 1, 0, 1, 0, 1],
222
+ [2, 1, 1, 0, 1, 0, 1],
223
+ [2, 1, 2, 0, 1, 0, 1],
224
+ [3, 1, 2, 0, 1, 0, 1],
225
+ [3, 1, 3, 0, 1, 0, 0],
226
+ [3, 1, 4, 1, 1, 0, 0],
227
+ [3, 1, 5, 3, 1, 0, 0],
228
+ [3, 1, 6, 4, 1, 0, 0]
229
+ ]
230
+ end
166
231
 
167
232
  create_hashes(parameters, expected)
168
233
  end
@@ -124,6 +124,13 @@ class PatriciaTrieTest < Test::Unit::TestCase
124
124
  end
125
125
  end
126
126
 
127
+ def test_key?
128
+ users = Groonga::PatriciaTrie.create(:name => "Users")
129
+ assert_false(users.key?("morita"))
130
+ users.add("morita")
131
+ assert_true(users.key?("morita"))
132
+ end
133
+
127
134
  def test_has_key?
128
135
  users = Groonga::PatriciaTrie.create(:name => "Users")
129
136
  assert_false(users.has_key?("morita"))
@@ -46,6 +46,13 @@ class VariableSizeColumnTest < Test::Unit::TestCase
46
46
  @users.define_column("nick_names", "ShortText",
47
47
  :type => :vector,
48
48
  :path => @users_nick_names_column_path.to_s)
49
+
50
+ @users_tags_column_path = @columns_dir + "tags"
51
+ @tags =
52
+ @users.define_column("tags", "ShortText",
53
+ :type => :vector,
54
+ :with_weight => true,
55
+ :path => @users_tags_column_path.to_s)
49
56
  end
50
57
 
51
58
  def setup_users
@@ -62,10 +69,22 @@ class VariableSizeColumnTest < Test::Unit::TestCase
62
69
  assert_predicate(@nick_names, :vector?)
63
70
  end
64
71
 
72
+ def test_weigth_vector?
73
+ assert do
74
+ @tags.weight_vector?
75
+ end
76
+ end
77
+
65
78
  def test_scalar?
66
79
  assert_not_predicate(@nick_names, :scalar?)
67
80
  end
68
81
 
82
+ def test_data?
83
+ assert do
84
+ @nick_names.data?
85
+ end
86
+ end
87
+
69
88
  def test_compressed?
70
89
  description = @users.define_column("description", "ShortText",
71
90
  :compress => :zlib)
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: 6.1.3
4
+ version: 7.0.2
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: 2017-01-12 00:00:00.000000000 Z
15
+ date: 2017-04-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pkg-config
@@ -194,10 +194,10 @@ email:
194
194
  - y.hayamizu@gmail.com
195
195
  - dara@shidara.net
196
196
  executables:
197
- - groonga-database-inspect
197
+ - groonga-index-dump
198
198
  - grndump
199
+ - groonga-database-inspect
199
200
  - grntest-log-analyze
200
- - groonga-index-dump
201
201
  extensions:
202
202
  - ext/groonga/extconf.rb
203
203
  extra_rdoc_files:
@@ -239,6 +239,7 @@ files:
239
239
  - ext/groonga/rb-grn-context.c
240
240
  - ext/groonga/rb-grn-data-column.c
241
241
  - ext/groonga/rb-grn-database.c
242
+ - ext/groonga/rb-grn-default-cache.c
242
243
  - ext/groonga/rb-grn-double-array-trie-cursor.c
243
244
  - ext/groonga/rb-grn-double-array-trie.c
244
245
  - ext/groonga/rb-grn-encoding-support.c
@@ -258,6 +259,7 @@ files:
258
259
  - ext/groonga/rb-grn-index-column.c
259
260
  - ext/groonga/rb-grn-index-cursor.c
260
261
  - ext/groonga/rb-grn-index.c
262
+ - ext/groonga/rb-grn-inverted-index-cursor.c
261
263
  - ext/groonga/rb-grn-less-equal-operator.c
262
264
  - ext/groonga/rb-grn-less-operator.c
263
265
  - ext/groonga/rb-grn-logger.c
@@ -335,6 +337,7 @@ files:
335
337
  - test/test-database-dumper.rb
336
338
  - test/test-database-inspector.rb
337
339
  - test/test-database.rb
340
+ - test/test-default-cache.rb
338
341
  - test/test-double-array-trie.rb
339
342
  - test/test-encoding.rb
340
343
  - test/test-error-message.rb
@@ -411,77 +414,78 @@ required_rubygems_version: !ruby/object:Gem::Requirement
411
414
  version: '0'
412
415
  requirements: []
413
416
  rubyforge_project:
414
- rubygems_version: 2.5.1
417
+ rubygems_version: 2.5.2
415
418
  signing_key:
416
419
  specification_version: 4
417
420
  summary: Ruby bindings for Groonga that provide full text search and column store
418
421
  features.
419
422
  test_files:
420
- - test/run-test.rb
421
- - test/test-error-message.rb
422
- - test/test-request-canceler.rb
423
- - test/test-normalizer.rb
424
- - test/test-database.rb
425
- - test/test-schema-type.rb
426
- - test/test-convert.rb
427
- - test/test-memory-pool.rb
428
- - test/test-gqtp.rb
429
- - test/test-id.rb
430
- - test/test-schema-create-table.rb
431
- - test/test-query-logger.rb
432
- - test/test-pagination.rb
433
- - test/test-expression-builder.rb
434
- - test/test-table-group.rb
435
423
  - test/test-schema.rb
436
- - test/test-operator.rb
437
- - test/test-expression.rb
438
- - test/test-name.rb
439
- - test/test-patricia-trie.rb
440
- - test/test-command-select.rb
441
- - test/test-context.rb
442
- - test/test-variable-size-column.rb
443
- - test/test-request-timer.rb
424
+ - test/test-snippet.rb
425
+ - test/test-request-canceler.rb
444
426
  - test/test-variable.rb
445
- - test/test-sub-records.rb
446
- - test/test-index-cursor.rb
427
+ - test/test-geo-point.rb
428
+ - test/test-plugin.rb
429
+ - test/test-table-group.rb
430
+ - test/test-accessor.rb
447
431
  - test/test-double-array-trie.rb
448
- - test/test-table-select.rb
449
- - test/test-windows-event-logger.rb
432
+ - test/test-pagination.rb
433
+ - test/test-memory-pool.rb
434
+ - test/test-request-timer.rb
435
+ - test/test-column.rb
450
436
  - test/test-table-traverse.rb
451
- - test/test-exception.rb
437
+ - test/test-expression.rb
438
+ - test/test-table-select.rb
439
+ - test/test-encoding.rb
440
+ - test/test-logger.rb
441
+ - test/test-schema-create-table.rb
442
+ - test/test-hash.rb
443
+ - test/test-type.rb
444
+ - test/test-table-offset-and-limit.rb
445
+ - test/test-version.rb
446
+ - test/test-data-column.rb
447
+ - test/test-lock-timeout.rb
452
448
  - test/test-index-column.rb
453
- - test/test-geo-point.rb
449
+ - test/test-table-key-support.rb
454
450
  - test/test-vector-column.rb
455
- - test/test-lock-timeout.rb
456
- - test/test-array.rb
457
- - test/test-schema-dumper.rb
458
- - test/test-fix-size-column.rb
459
- - test/test-table-select-mecab.rb
451
+ - test/test-error-message.rb
452
+ - test/test-normalizer.rb
453
+ - test/test-table-select-weight.rb
454
+ - test/test-schema-type.rb
455
+ - test/test-sub-records.rb
460
456
  - test/test-procedure.rb
457
+ - test/test-config.rb
458
+ - test/test-context.rb
459
+ - test/test-gqtp.rb
460
+ - test/test-remote.rb
461
461
  - test/test-database-dumper.rb
462
+ - test/test-name.rb
462
463
  - test/test-database-inspector.rb
463
- - test/test-package-label.rb
464
- - test/test-data-column.rb
465
- - test/test-table-key-support.rb
466
- - test/test-table-offset-and-limit.rb
467
- - test/test-accessor.rb
468
- - test/test-remote.rb
469
- - test/test-plugin.rb
464
+ - test/test-id.rb
465
+ - test/test-patricia-trie.rb
466
+ - test/run-test.rb
467
+ - test/test-fix-size-column.rb
468
+ - test/test-statistic-measurer.rb
469
+ - test/test-array.rb
470
+ - test/test-table.rb
470
471
  - test/groonga-test-utils.rb
471
- - test/test-column.rb
472
472
  - test/test-record.rb
473
- - test/test-hash.rb
474
- - test/test-logger.rb
475
- - test/test-table-select-weight.rb
476
- - test/test-version.rb
473
+ - test/test-exception.rb
477
474
  - test/test-table-select-normalize.rb
478
- - test/test-config.rb
479
- - test/test-flushable.rb
480
- - test/test-encoding.rb
481
475
  - test/test-thread.rb
482
- - test/test-snippet.rb
483
- - test/test-type.rb
484
- - test/test-table.rb
485
- - test/test-table-dumper.rb
486
- - test/test-statistic-measurer.rb
476
+ - test/test-schema-dumper.rb
487
477
  - test/test-token-regexp.rb
478
+ - test/test-table-dumper.rb
479
+ - test/test-database.rb
480
+ - test/test-query-logger.rb
481
+ - test/test-package-label.rb
482
+ - test/test-variable-size-column.rb
483
+ - test/test-default-cache.rb
484
+ - test/test-table-select-mecab.rb
485
+ - test/test-windows-event-logger.rb
486
+ - test/test-expression-builder.rb
487
+ - test/test-operator.rb
488
+ - test/test-flushable.rb
489
+ - test/test-convert.rb
490
+ - test/test-index-cursor.rb
491
+ - test/test-command-select.rb