rroonga 3.0.9 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +10 -10
- data/bin/groonga-database-inspect +40 -0
- data/doc/text/news.textile +19 -0
- data/ext/groonga/extconf.rb +3 -1
- data/ext/groonga/rb-grn-expression.c +1 -1
- data/ext/groonga/rb-grn-operator.c +218 -8
- data/ext/groonga/rb-grn.h +4 -2
- data/lib/groonga.rb +4 -1
- data/lib/groonga/column.rb +25 -0
- data/lib/groonga/database-inspector.rb +279 -0
- data/lib/groonga/database.rb +32 -2
- data/lib/groonga/dumper.rb +7 -13
- data/lib/groonga/index-column.rb +11 -1
- data/lib/groonga/statistic-measurer.rb +37 -0
- data/lib/groonga/table.rb +25 -0
- data/rroonga-build.rb +2 -2
- data/test/groonga-test-utils.rb +10 -10
- data/test/test-column.rb +26 -0
- data/test/test-database-inspector.rb +676 -0
- data/test/test-database.rb +25 -1
- data/test/test-expression-builder.rb +1 -0
- data/test/test-expression.rb +73 -0
- data/test/test-index-column.rb +23 -0
- data/test/test-statistic-measurer.rb +55 -0
- data/test/test-table.rb +40 -0
- metadata +17 -8
- data/lib/groonga/view-record.rb +0 -50
data/test/test-database.rb
CHANGED
@@ -172,7 +172,14 @@ class DatabaseTest < Test::Unit::TestCase
|
|
172
172
|
@database.tables.collect(&:name).sort)
|
173
173
|
end
|
174
174
|
|
175
|
-
|
175
|
+
def test_plugin_paths
|
176
|
+
setup_database
|
177
|
+
context.register_plugin("query_expanders/tsv")
|
178
|
+
assert_equal(["query_expanders/tsv#{Groonga::Plugin.suffix}"],
|
179
|
+
@database.plugin_paths)
|
180
|
+
end
|
181
|
+
|
182
|
+
class RemoveTest < self
|
176
183
|
setup :setup_database
|
177
184
|
|
178
185
|
def test_referenced_table
|
@@ -245,4 +252,21 @@ class DatabaseTest < Test::Unit::TestCase
|
|
245
252
|
assert_false(File.exist?(path))
|
246
253
|
end
|
247
254
|
end
|
255
|
+
|
256
|
+
class DiskUsageTest < self
|
257
|
+
setup :setup_database
|
258
|
+
|
259
|
+
def test_empty
|
260
|
+
paths = [
|
261
|
+
@database.path,
|
262
|
+
"#{@database.path}.001",
|
263
|
+
"#{@database.path}.0000000",
|
264
|
+
]
|
265
|
+
expected_usage = paths.inject(0) do |previous, path|
|
266
|
+
previous + File.size(path)
|
267
|
+
end
|
268
|
+
assert_equal(expected_usage,
|
269
|
+
@database.disk_usage)
|
270
|
+
end
|
271
|
+
end
|
248
272
|
end
|
data/test/test-expression.rb
CHANGED
@@ -141,4 +141,77 @@ class ExpressionTest < Test::Unit::TestCase
|
|
141
141
|
assert_equal("TODO: Change me to expression", variable.value)
|
142
142
|
end
|
143
143
|
end
|
144
|
+
|
145
|
+
class ParseTest < self
|
146
|
+
setup
|
147
|
+
def setup_schema
|
148
|
+
Groonga::Schema.define do |schema|
|
149
|
+
schema.create_table("Users") do
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
setup
|
155
|
+
def setup_expression
|
156
|
+
@expression = Groonga::Expression.new
|
157
|
+
@variable = @expression.define_variable
|
158
|
+
@variable.value = Groonga["Users"].add
|
159
|
+
end
|
160
|
+
|
161
|
+
class DefaultOperatorTest < self
|
162
|
+
def test_nil
|
163
|
+
assert_equal("AND", parse(nil))
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_name
|
167
|
+
assert_equal("OR", parse("or"))
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_name_symbol
|
171
|
+
assert_equal("OR", parse(:or))
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_symbol
|
175
|
+
assert_equal("OR", parse("||"))
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_integer
|
179
|
+
assert_equal("ADJUST", parse(Groonga::Operator::ADJUST))
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
def parse(default_operator)
|
184
|
+
@expression.parse("_id:1 _id:2", :default_operator => default_operator)
|
185
|
+
operator = @expression.inspect[/\d([a-zA-Z_-]+)}/, 1]
|
186
|
+
operator
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
class DefaultModeTest < self
|
191
|
+
def test_nil
|
192
|
+
assert_equal("MATCH", parse(nil))
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_name
|
196
|
+
assert_equal("EQUAL", parse("equal"))
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_symbol
|
200
|
+
assert_equal("EQUAL", parse(:equal))
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_integer
|
204
|
+
assert_equal("EQUAL", parse(Groonga::Operator::EQUAL))
|
205
|
+
end
|
206
|
+
|
207
|
+
private
|
208
|
+
def parse(default_mode)
|
209
|
+
@expression.parse("query",
|
210
|
+
:default_column => "_id",
|
211
|
+
:default_mode => default_mode)
|
212
|
+
operator = @expression.inspect[/\d([a-zA-Z_-]+)}/, 1]
|
213
|
+
operator
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
144
217
|
end
|
data/test/test-index-column.rb
CHANGED
@@ -342,4 +342,27 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
342
342
|
end
|
343
343
|
end
|
344
344
|
end
|
345
|
+
|
346
|
+
class DiskUsageTest < self
|
347
|
+
def setup
|
348
|
+
setup_database
|
349
|
+
setup_index
|
350
|
+
end
|
351
|
+
|
352
|
+
def setup_index
|
353
|
+
articles = Groonga::Array.create(:name => "Articles")
|
354
|
+
articles.define_column("content", "Text")
|
355
|
+
|
356
|
+
terms = Groonga::Hash.create(:name => "Terms",
|
357
|
+
:key_type => "ShortText",
|
358
|
+
:default_tokenizer => "TokenBigram")
|
359
|
+
@index = terms.define_index_column("content", articles,
|
360
|
+
:with_section => true)
|
361
|
+
end
|
362
|
+
|
363
|
+
def test_disk_usage
|
364
|
+
assert_equal(File.size(@index.path) + File.size("#{@index.path}.c"),
|
365
|
+
@index.disk_usage)
|
366
|
+
end
|
367
|
+
end
|
345
368
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright (C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
class StatisticMeasurerTest < Test::Unit::TestCase
|
17
|
+
include GroongaTestUtils
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@measurer = Groonga::StatisticMeasurer.new
|
21
|
+
end
|
22
|
+
|
23
|
+
class DiskUsageTest < self
|
24
|
+
def test_nil
|
25
|
+
assert_equal(0, disk_usage(nil))
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_path_only
|
29
|
+
size = 5
|
30
|
+
path = File.join(@tmp_dir, "db")
|
31
|
+
write(path, "X" * size)
|
32
|
+
assert_equal(size, disk_usage(path))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_additional_path
|
36
|
+
size_per_file = 5
|
37
|
+
path = File.join(@tmp_dir, "db")
|
38
|
+
write(path, "X" * size_per_file)
|
39
|
+
write("#{path}.001", "X" * size_per_file)
|
40
|
+
write("#{path}.002", "X" * size_per_file)
|
41
|
+
assert_equal(3 * size_per_file, disk_usage(path))
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def disk_usage(path)
|
46
|
+
@measurer.measure_disk_usage(path)
|
47
|
+
end
|
48
|
+
|
49
|
+
def write(path, content)
|
50
|
+
File.open(path, "w") do |file|
|
51
|
+
file.write(content)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/test/test-table.rb
CHANGED
@@ -837,6 +837,46 @@ class TableTest < Test::Unit::TestCase
|
|
837
837
|
end
|
838
838
|
end
|
839
839
|
|
840
|
+
class DiskUsageTest < self
|
841
|
+
def test_array
|
842
|
+
Groonga::Schema.create_table("Users", :type => :array)
|
843
|
+
users = Groonga["Users"]
|
844
|
+
users.add
|
845
|
+
assert_equal(File.size(users.path),
|
846
|
+
users.disk_usage)
|
847
|
+
end
|
848
|
+
|
849
|
+
def test_hash
|
850
|
+
Groonga::Schema.create_table("Users",
|
851
|
+
:type => :hash,
|
852
|
+
:key_type => "ShortText")
|
853
|
+
users = Groonga["Users"]
|
854
|
+
users.add("mori")
|
855
|
+
assert_equal(File.size(users.path),
|
856
|
+
users.disk_usage)
|
857
|
+
end
|
858
|
+
|
859
|
+
def test_patricia_trie
|
860
|
+
Groonga::Schema.create_table("Users",
|
861
|
+
:type => :patricia_trie,
|
862
|
+
:key_type => "ShortText")
|
863
|
+
users = Groonga["Users"]
|
864
|
+
users.add("mori")
|
865
|
+
assert_equal(File.size(users.path),
|
866
|
+
users.disk_usage)
|
867
|
+
end
|
868
|
+
|
869
|
+
def test_double_array_trie
|
870
|
+
Groonga::Schema.create_table("Users",
|
871
|
+
:type => :double_array_trie,
|
872
|
+
:key_type => "ShortText")
|
873
|
+
users = Groonga["Users"]
|
874
|
+
users.add("mori")
|
875
|
+
assert_equal(File.size(users.path) + File.size("#{users.path}.001"),
|
876
|
+
users.disk_usage)
|
877
|
+
end
|
878
|
+
end
|
879
|
+
|
840
880
|
private
|
841
881
|
def create_bookmarks
|
842
882
|
bookmarks = Groonga::Array.create(:name => "Bookmarks")
|
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: 3.0
|
4
|
+
version: 3.1.0
|
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: 2013-
|
15
|
+
date: 2013-11-29 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: pkg-config
|
@@ -183,9 +183,9 @@ dependencies:
|
|
183
183
|
- !ruby/object:Gem::Version
|
184
184
|
version: '0'
|
185
185
|
description: |-
|
186
|
-
|
187
|
-
layer.
|
188
|
-
not C like API. You can use
|
186
|
+
Rroonga is an extension library to use Groonga's DB-API
|
187
|
+
layer. Rroonga provides Rubyish readable and writable API
|
188
|
+
not C like API. You can use Groonga's fast and highly
|
189
189
|
functional features from Ruby with Rubyish form.
|
190
190
|
email:
|
191
191
|
- kou@clear-code.com
|
@@ -194,6 +194,7 @@ email:
|
|
194
194
|
- y.hayamizu@gmail.com
|
195
195
|
- dara@shidara.net
|
196
196
|
executables:
|
197
|
+
- groonga-database-inspect
|
197
198
|
- groonga-index-dump
|
198
199
|
- grntest-log-analyze
|
199
200
|
- grndump
|
@@ -218,15 +219,18 @@ files:
|
|
218
219
|
- lib/groonga/sub-records.rb
|
219
220
|
- lib/groonga/pagination.rb
|
220
221
|
- lib/groonga/index-column.rb
|
221
|
-
- lib/groonga/view-record.rb
|
222
222
|
- lib/groonga/patricia-trie.rb
|
223
|
+
- lib/groonga/database-inspector.rb
|
223
224
|
- lib/groonga/context/command-executor.rb
|
225
|
+
- lib/groonga/statistic-measurer.rb
|
224
226
|
- lib/groonga/grntest-log.rb
|
225
227
|
- lib/groonga/dumper.rb
|
226
228
|
- lib/groonga/posting.rb
|
227
229
|
- lib/groonga/memory-pool.rb
|
230
|
+
- lib/groonga/table.rb
|
228
231
|
- lib/groonga/query-logger.rb
|
229
232
|
- lib/groonga/context.rb
|
233
|
+
- lib/groonga/column.rb
|
230
234
|
- lib/groonga/record.rb
|
231
235
|
- lib/groonga/expression-builder.rb
|
232
236
|
- lib/groonga/logger.rb
|
@@ -288,6 +292,7 @@ files:
|
|
288
292
|
- test/test-vector-column.rb
|
289
293
|
- test/test-schema-dumper.rb
|
290
294
|
- test/run-test.rb
|
295
|
+
- test/test-database-inspector.rb
|
291
296
|
- test/test-procedure.rb
|
292
297
|
- test/test-hash.rb
|
293
298
|
- test/test-expression.rb
|
@@ -298,6 +303,7 @@ files:
|
|
298
303
|
- test/test-sub-records.rb
|
299
304
|
- test/test-encoding.rb
|
300
305
|
- test/test-snippet.rb
|
306
|
+
- test/test-statistic-measurer.rb
|
301
307
|
- test/test-index-cursor.rb
|
302
308
|
- test/test-type.rb
|
303
309
|
- test/test-table-dumper.rb
|
@@ -333,6 +339,7 @@ files:
|
|
333
339
|
- test/test-database.rb
|
334
340
|
- test/test-double-array-trie.rb
|
335
341
|
- test/test-record.rb
|
342
|
+
- bin/groonga-database-inspect
|
336
343
|
- bin/groonga-index-dump
|
337
344
|
- bin/grntest-log-analyze
|
338
345
|
- bin/grndump
|
@@ -357,10 +364,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
357
364
|
version: '0'
|
358
365
|
requirements: []
|
359
366
|
rubyforge_project: groonga
|
360
|
-
rubygems_version: 2.0.
|
367
|
+
rubygems_version: 2.0.13
|
361
368
|
signing_key:
|
362
369
|
specification_version: 4
|
363
|
-
summary: Ruby bindings for
|
370
|
+
summary: Ruby bindings for Groonga that provide full text search and column store
|
364
371
|
features.
|
365
372
|
test_files:
|
366
373
|
- test/test-normalizer.rb
|
@@ -368,6 +375,7 @@ test_files:
|
|
368
375
|
- test/test-vector-column.rb
|
369
376
|
- test/test-schema-dumper.rb
|
370
377
|
- test/run-test.rb
|
378
|
+
- test/test-database-inspector.rb
|
371
379
|
- test/test-procedure.rb
|
372
380
|
- test/test-hash.rb
|
373
381
|
- test/test-expression.rb
|
@@ -378,6 +386,7 @@ test_files:
|
|
378
386
|
- test/test-sub-records.rb
|
379
387
|
- test/test-encoding.rb
|
380
388
|
- test/test-snippet.rb
|
389
|
+
- test/test-statistic-measurer.rb
|
381
390
|
- test/test-index-cursor.rb
|
382
391
|
- test/test-type.rb
|
383
392
|
- test/test-table-dumper.rb
|
data/lib/groonga/view-record.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright (C) 2010 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
|
-
module Groonga
|
19
|
-
class ViewRecord
|
20
|
-
# レコードが所属するビュー
|
21
|
-
attr_reader :view
|
22
|
-
# レコードのID
|
23
|
-
attr_reader :id
|
24
|
-
|
25
|
-
# _table_ の _id_ に対応するレコードを作成する。
|
26
|
-
def initialize(view, id)
|
27
|
-
@view = view
|
28
|
-
@id = id
|
29
|
-
end
|
30
|
-
|
31
|
-
# _record_ と _other_ が同じgroongaのレコードなら +true+ を返し、
|
32
|
-
# そうでなければ +false+ を返す。
|
33
|
-
def ==(other)
|
34
|
-
self.class == other.class and
|
35
|
-
[view, id] == [other.view, other.id]
|
36
|
-
end
|
37
|
-
|
38
|
-
# このレコードの _column_name_ で指定されたカラムの値を返す。
|
39
|
-
def [](column_name)
|
40
|
-
@view.column_value(@id, column_name)
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def method_missing(name, *args, &block)
|
45
|
-
return super if /(?:=|\?)\z/ =~ name.to_s
|
46
|
-
return super unless args.empty?
|
47
|
-
self[name.to_s]
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|