rroonga 1.3.0 → 1.3.1
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 +33 -2
- data/benchmark/common.rb +2 -2
- data/benchmark/read-write-many-small-items.rb +71 -62
- data/benchmark/write-many-small-items.rb +61 -53
- data/ext/groonga/rb-grn-context.c +23 -5
- data/ext/groonga/rb-grn-index-column.c +2 -6
- data/ext/groonga/rb-grn-operator.c +31 -1
- data/ext/groonga/rb-grn-variable-size-column.c +77 -1
- data/ext/groonga/rb-grn.h +2 -11
- data/ext/groonga/rb-groonga.c +1 -2
- data/lib/groonga/command.rb +169 -0
- data/lib/groonga/context.rb +4 -124
- data/lib/groonga/dumper.rb +10 -8
- data/lib/groonga/record.rb +7 -0
- data/lib/groonga/schema.rb +98 -7
- data/rroonga-build.rb +3 -3
- data/test/{test-context-select.rb → test-command-select.rb} +3 -3
- data/test/test-record.rb +18 -1
- data/test/test-schema-dumper.rb +48 -0
- data/test/test-schema-type.rb +35 -0
- data/test/test-schema.rb +81 -11
- data/test/test-table-select.rb +49 -38
- data/test/test-variable-size-column.rb +30 -0
- metadata +80 -82
- data/ext/groonga/rb-grn-query.c +0 -260
- data/test/test-query.rb +0 -22
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8; mode: ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2009-
|
3
|
+
# Copyright (C) 2009-2012 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -168,7 +168,38 @@ relative_binary_dir = File.join("vendor", "local")
|
|
168
168
|
vendor_dir = File.join(base_dir, relative_vendor_dir)
|
169
169
|
binary_dir = File.join(base_dir, relative_binary_dir)
|
170
170
|
|
171
|
-
groonga_win32_i386_p = ENV["
|
171
|
+
groonga_win32_i386_p = ENV["GROONGA64"] != "yes"
|
172
|
+
|
173
|
+
namespace :win32 do
|
174
|
+
namespace :groonga do
|
175
|
+
task :download do
|
176
|
+
require "open-uri"
|
177
|
+
require "rroonga-build"
|
178
|
+
groonga_version = RroongaBuild::RequiredGroongaVersion::VERSION.join(".")
|
179
|
+
base_name = "groonga-#{groonga_version}-"
|
180
|
+
if groonga_win32_i386_p
|
181
|
+
base_name << "x86"
|
182
|
+
else
|
183
|
+
base_name << "x64"
|
184
|
+
end
|
185
|
+
base_name << ".zip"
|
186
|
+
base_url = "http://packages.groonga.org/windows/groonga/"
|
187
|
+
Dir.chdir(base_dir) do
|
188
|
+
unless File.exist?(base_name)
|
189
|
+
open("#{base_url}#{base_name}", "rb") do |zip|
|
190
|
+
File.open(base_name, "wb") do |output|
|
191
|
+
output.print(zip.read)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
sh("unzip", base_name)
|
196
|
+
rm_rf(relative_binary_dir)
|
197
|
+
mkdir_p(File.dirname(relative_binary_dir))
|
198
|
+
mv(File.basename(base_name, ".*"), relative_binary_dir)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
172
203
|
|
173
204
|
Rake::ExtensionTask.new("groonga", spec) do |ext|
|
174
205
|
if groonga_win32_i386_p
|
data/benchmark/common.rb
CHANGED
@@ -35,7 +35,7 @@ def report(index=0)
|
|
35
35
|
end
|
36
36
|
|
37
37
|
if index.zero?
|
38
|
-
puts(" " * (width - 1) + Benchmark::Tms::CAPTION.rstrip + "memory".rjust(
|
38
|
+
puts(" " * (width - 1) + Benchmark::Tms::CAPTION.rstrip + "memory".rjust(11))
|
39
39
|
end
|
40
40
|
# GC.disable
|
41
41
|
before = memory_usage
|
@@ -44,6 +44,6 @@ def report(index=0)
|
|
44
44
|
GC.start
|
45
45
|
size = memory_usage - before
|
46
46
|
|
47
|
-
formatted_size = "%
|
47
|
+
formatted_size = "%7.3f" % size
|
48
48
|
puts "#{label.ljust(width)} #{result.to_s.strip} #{formatted_size}MB"
|
49
49
|
end
|
@@ -3,32 +3,31 @@
|
|
3
3
|
# This benchmark is based on Tokyo Cabinet's benchmark at
|
4
4
|
# http://alpha.mixi.co.jp/blog/?p=791
|
5
5
|
#
|
6
|
-
# On my environment at
|
7
|
-
# % for x in {0..
|
8
|
-
#
|
9
|
-
# Hash
|
10
|
-
# groonga: Hash
|
11
|
-
# groonga:
|
12
|
-
# groonga:
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# TC:
|
16
|
-
# TC:
|
17
|
-
# TC:
|
18
|
-
# TC: Tree: file 1.290000 0.180000 1.470000 ( 1.476853) 12.805MB
|
6
|
+
# On my environment at 2012/01/25:
|
7
|
+
# % for x in {0..8}; do ruby1.9.1 benchmark/read-write-many-small-items.rb $x; done
|
8
|
+
# user system total real memory
|
9
|
+
# Hash 0.410000 0.000000 0.410000 ( 0.412228) 44.895MB
|
10
|
+
# groonga: Hash 0.910000 0.030000 0.940000 ( 0.938278) 38.863MB
|
11
|
+
# groonga: PatriciaTrie 1.050000 0.020000 1.070000 ( 1.076237) 34.832MB
|
12
|
+
# groonga: DoubleArrayTrie 1.050000 0.040000 1.090000 ( 1.083912) 34.852MB
|
13
|
+
# Localmemcache: file 0.610000 0.040000 0.650000 ( 0.641539) 61.441MB
|
14
|
+
# TC: Hash: memory 0.470000 0.010000 0.480000 ( 0.477577) 55.910MB
|
15
|
+
# TC: Tree: memory 0.430000 0.010000 0.440000 ( 0.441939) 44.484MB
|
16
|
+
# TC: Hash: file 0.980000 0.990000 1.970000 ( 1.971581) 17.684MB
|
17
|
+
# TC: Tree: file 0.650000 0.030000 0.680000 ( 0.683004) 19.801MB
|
19
18
|
#
|
20
|
-
# CPU: Intel(R) Core(TM)
|
21
|
-
# Memory:
|
22
|
-
# Ruby: Debian GNU/Linux sid at
|
23
|
-
# ruby 1.
|
24
|
-
# groonga: HEAD at
|
25
|
-
#
|
26
|
-
# Localmemcache:
|
27
|
-
# Tokyo Cabinet: 1.4.
|
28
|
-
# Tokyo Cabinet Ruby: 1.
|
19
|
+
# CPU: Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz stepping 05
|
20
|
+
# Memory: 8GB
|
21
|
+
# Ruby: Debian GNU/Linux sid at 2012/01/25:
|
22
|
+
# ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
|
23
|
+
# groonga: HEAD at 2012/01/25: 07dce043cc8cfbbecbcdc43bf7c6d5c2d085237a
|
24
|
+
# rroonga: master at 2012/01/25: 29099bff93377733d81dc2398c3403e1293301dc
|
25
|
+
# Localmemcache: 0.4.4
|
26
|
+
# Tokyo Cabinet: 1.4.37
|
27
|
+
# Tokyo Cabinet Ruby: 1.31
|
29
28
|
#
|
30
29
|
# NOTE:
|
31
|
-
# * groonga, Localmemcache and Tokyo Cabinet are built with "-
|
30
|
+
# * groonga, Localmemcache and Tokyo Cabinet are built with "-O2" option.
|
32
31
|
# * Ruby bindings of them are built with "-O2" option.
|
33
32
|
|
34
33
|
require File.join(File.dirname(__FILE__), "common.rb")
|
@@ -40,44 +39,54 @@ n.times do |i|
|
|
40
39
|
values << "%08d" % i
|
41
40
|
end
|
42
41
|
|
42
|
+
ruby_hash = {}
|
43
43
|
item("Hash") do
|
44
|
-
@hash = {}
|
45
44
|
values.each do |value|
|
46
|
-
|
47
|
-
|
45
|
+
ruby_hash[value] = value
|
46
|
+
ruby_hash[value]
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
50
|
begin
|
52
51
|
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
53
|
-
$LOAD_PATH.unshift(File.join(base_dir, "ext"))
|
52
|
+
$LOAD_PATH.unshift(File.join(base_dir, "ext", "groonga"))
|
54
53
|
$LOAD_PATH.unshift(File.join(base_dir, "lib"))
|
55
54
|
|
56
55
|
require 'groonga'
|
57
56
|
tmp_dir = "/tmp/groonga"
|
58
57
|
FileUtils.rm_rf(tmp_dir)
|
59
58
|
FileUtils.mkdir(tmp_dir)
|
59
|
+
Groonga::Context.default.encoding = :none
|
60
60
|
@database = Groonga::Database.create(:path => "#{tmp_dir}/db")
|
61
|
+
column_name = "value"
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@column = @hash.define_column(column_name, "ShortText")
|
63
|
+
groonga_hash = Groonga::Hash.create(:name => "Hash",
|
64
|
+
:key_type => "ShortText")
|
65
|
+
groonga_hash.define_column(column_name, "ShortText")
|
66
|
+
item("groonga: Hash") do
|
67
67
|
values.each do |value|
|
68
|
-
|
69
|
-
|
68
|
+
groonga_hash.set_column_value(value, column_name, value)
|
69
|
+
groonga_hash.column_value(value, column_name)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
@column = @trie.define_column(column_name, "ShortText")
|
73
|
+
patricia_trie = Groonga::PatriciaTrie.create(:name => "PatriciaTrie",
|
74
|
+
:key_type => "ShortText")
|
75
|
+
patricia_trie.define_column(column_name, "ShortText")
|
76
|
+
item("groonga: PatriciaTrie") do
|
78
77
|
values.each do |value|
|
79
|
-
|
80
|
-
|
78
|
+
patricia_trie.set_column_value(value, column_name, value)
|
79
|
+
patricia_trie.column_value(value, column_name)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
double_array_trie = Groonga::DoubleArrayTrie.create(:name => "DoubleArrayTrie",
|
84
|
+
:key_type => "ShortText")
|
85
|
+
double_array_trie.define_column(column_name, "ShortText")
|
86
|
+
item("groonga: DoubleArrayTrie") do
|
87
|
+
values.each do |value|
|
88
|
+
patricia_trie.set_column_value(value, column_name, value)
|
89
|
+
patricia_trie.column_value(value, column_name)
|
81
90
|
end
|
82
91
|
end
|
83
92
|
rescue LoadError
|
@@ -86,13 +95,13 @@ end
|
|
86
95
|
begin
|
87
96
|
require 'localmemcache'
|
88
97
|
|
98
|
+
LocalMemCache.drop(:namespace => "read-write-many-small-items",
|
99
|
+
:force => true)
|
100
|
+
mem_cache = LocalMemCache.new(:namespace => "read-write-many-small-items")
|
89
101
|
item("Localmemcache: file") do
|
90
|
-
LocalMemCache.drop(:namespace => "read-write-many-small-items",
|
91
|
-
:force => true)
|
92
|
-
@db = LocalMemCache.new(:namespace => "read-write-many-small-items")
|
93
102
|
values.each do |value|
|
94
|
-
|
95
|
-
|
103
|
+
mem_cache[value] = value
|
104
|
+
mem_cache[value]
|
96
105
|
end
|
97
106
|
end
|
98
107
|
rescue LoadError
|
@@ -101,41 +110,41 @@ end
|
|
101
110
|
begin
|
102
111
|
require 'tokyocabinet'
|
103
112
|
|
113
|
+
tc_hash_memory = TokyoCabinet::ADB::new
|
114
|
+
tc_hash_memory.open("*#bnum=#{n}#mode=wct#xmsiz=0")
|
104
115
|
item("TC: Hash: memory") do
|
105
|
-
@db = TokyoCabinet::ADB::new
|
106
|
-
@db.open("*#bnum=#{n}#mode=wct#xmsiz=0")
|
107
116
|
values.each do |value|
|
108
|
-
|
109
|
-
|
117
|
+
tc_hash_memory.put(value, value)
|
118
|
+
tc_hash_memory.get(value)
|
110
119
|
end
|
111
120
|
end
|
112
121
|
|
122
|
+
tc_tree_memory = TokyoCabinet::ADB::new
|
123
|
+
tc_tree_memory.open("+#bnum=#{n}#mode=wct#xmsiz=0")
|
113
124
|
item("TC: Tree: memory") do
|
114
|
-
@db = TokyoCabinet::ADB::new
|
115
|
-
@db.open("+#bnum=#{n}#mode=wct#xmsiz=0")
|
116
125
|
values.each do |value|
|
117
|
-
|
118
|
-
|
126
|
+
tc_tree_memory.put(value, value)
|
127
|
+
tc_tree_memory.get(value)
|
119
128
|
end
|
120
129
|
end
|
121
130
|
|
122
131
|
hash_file = Tempfile.new(["tc-hash", ".tch"])
|
132
|
+
tc_hash_file = TokyoCabinet::ADB::new
|
133
|
+
tc_hash_file.open("#{hash_file.path}#bnum=#{n}#mode=wct#xmsiz=0")
|
123
134
|
item("TC: Hash: file") do
|
124
|
-
@db = TokyoCabinet::ADB::new
|
125
|
-
@db.open("#{hash_file.path}#bnum=#{n}#mode=wct#xmsiz=0")
|
126
135
|
values.each do |value|
|
127
|
-
|
128
|
-
|
136
|
+
tc_hash_file.put(value, value)
|
137
|
+
tc_hash_file.get(value)
|
129
138
|
end
|
130
139
|
end
|
131
140
|
|
132
141
|
tree_file = Tempfile.new(["tc-tree", ".tcb"])
|
142
|
+
tc_tree_file = TokyoCabinet::ADB::new
|
143
|
+
tc_tree_file.open("#{tree_file.path}#bnum=#{n}#mode=wct#xmsiz=0")
|
133
144
|
item("TC: Tree: file") do
|
134
|
-
@db = TokyoCabinet::ADB::new
|
135
|
-
@db.open("#{tree_file.path}#bnum=#{n}#mode=wct#xmsiz=0")
|
136
145
|
values.each do |value|
|
137
|
-
|
138
|
-
|
146
|
+
tc_tree_file.put(value, value)
|
147
|
+
tc_tree_file.get(value)
|
139
148
|
end
|
140
149
|
end
|
141
150
|
rescue LoadError
|
@@ -3,32 +3,31 @@
|
|
3
3
|
# This benchmark is based on Tokyo Cabinet's benchmark at
|
4
4
|
# http://alpha.mixi.co.jp/blog/?p=791
|
5
5
|
#
|
6
|
-
# On my environment at
|
7
|
-
# % for x in {0..
|
8
|
-
#
|
9
|
-
# Hash
|
10
|
-
# groonga: Hash
|
11
|
-
# groonga:
|
12
|
-
# groonga:
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# TC:
|
16
|
-
# TC:
|
17
|
-
# TC:
|
18
|
-
# TC: Tree: file 0.720000 0.130000 0.850000 ( 0.877557) 6.102MB
|
6
|
+
# On my environment at 2012/01/25:
|
7
|
+
# % for x in {0..8}; do ruby1.9.1 benchmark/write-many-small-items.rb $x; done
|
8
|
+
# user system total real memory
|
9
|
+
# Hash 0.320000 0.030000 0.350000 ( 0.345441) 44.910MB
|
10
|
+
# groonga: Hash 0.490000 0.020000 0.510000 ( 0.512336) 23.305MB
|
11
|
+
# groonga: PatriciaTrie 0.560000 0.010000 0.570000 ( 0.572077) 19.242MB
|
12
|
+
# groonga: DoubleArrayTrie 0.700000 0.020000 0.720000 ( 0.730448) 39.789MB
|
13
|
+
# Localmemcache: file 0.510000 0.040000 0.550000 ( 0.549663) 45.898MB
|
14
|
+
# TC: Hash: memory 0.270000 0.020000 0.290000 ( 0.292051) 40.148MB
|
15
|
+
# TC: Tree: memory 0.220000 0.010000 0.230000 ( 0.229233) 28.727MB
|
16
|
+
# TC: Hash: file 0.610000 0.630000 1.240000 ( 1.247094) 2.129MB
|
17
|
+
# TC: Tree: file 0.340000 0.040000 0.380000 ( 0.377910) 4.000MB
|
19
18
|
#
|
20
|
-
# CPU: Intel(R) Core(TM)
|
21
|
-
# Memory:
|
22
|
-
# Ruby: Debian GNU/Linux sid at
|
23
|
-
# ruby 1.
|
24
|
-
# groonga: HEAD at
|
25
|
-
#
|
26
|
-
# Localmemcache:
|
27
|
-
# Tokyo Cabinet: 1.4.
|
28
|
-
# Tokyo Cabinet Ruby: 1.
|
19
|
+
# CPU: Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz stepping 05
|
20
|
+
# Memory: 8GB
|
21
|
+
# Ruby: Debian GNU/Linux sid at 2012/01/25:
|
22
|
+
# ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
|
23
|
+
# groonga: HEAD at 2012/01/25: 07dce043cc8cfbbecbcdc43bf7c6d5c2d085237a
|
24
|
+
# rroonga: master at 2012/01/25: 29099bff93377733d81dc2398c3403e1293301dc
|
25
|
+
# Localmemcache: 0.4.4
|
26
|
+
# Tokyo Cabinet: 1.4.37
|
27
|
+
# Tokyo Cabinet Ruby: 1.31
|
29
28
|
#
|
30
29
|
# NOTE:
|
31
|
-
# * groonga, Localmemcache and Tokyo Cabinet are built with "-
|
30
|
+
# * groonga, Localmemcache and Tokyo Cabinet are built with "-O2" option.
|
32
31
|
# * Ruby bindings of them are built with "-O2" option.
|
33
32
|
|
34
33
|
require File.join(File.dirname(__FILE__), "common.rb")
|
@@ -40,41 +39,50 @@ n.times do |i|
|
|
40
39
|
values << "%08d" % i
|
41
40
|
end
|
42
41
|
|
42
|
+
ruby_hash = {}
|
43
43
|
item("Hash") do
|
44
|
-
@hash = {}
|
45
44
|
values.each do |value|
|
46
|
-
|
45
|
+
ruby_hash[value] = value
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
49
|
begin
|
51
50
|
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
52
|
-
$LOAD_PATH.unshift(File.join(base_dir, "ext"))
|
51
|
+
$LOAD_PATH.unshift(File.join(base_dir, "ext", "groonga"))
|
53
52
|
$LOAD_PATH.unshift(File.join(base_dir, "lib"))
|
54
53
|
|
55
54
|
require 'groonga'
|
56
55
|
tmp_dir = "/tmp/groonga"
|
57
56
|
FileUtils.rm_rf(tmp_dir)
|
58
57
|
FileUtils.mkdir(tmp_dir)
|
58
|
+
Groonga::Context.default.encoding = :none
|
59
59
|
@database = Groonga::Database.create(:path => "#{tmp_dir}/db")
|
60
|
+
column_name = "value"
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
@column = @hash.define_column(column_name, "ShortText")
|
62
|
+
groonga_hash = Groonga::Hash.create(:name => "Hash",
|
63
|
+
:key_type => "ShortText")
|
64
|
+
groonga_hash.define_column(column_name, "ShortText")
|
65
|
+
item("groonga: Hash") do
|
66
66
|
values.each do |value|
|
67
|
-
|
67
|
+
groonga_hash.set_column_value(value, column_name, value)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
@column = @trie.define_column(column_name, "ShortText")
|
71
|
+
patricia_trie = Groonga::PatriciaTrie.create(:name => "PatriciaTrie",
|
72
|
+
:key_type => "ShortText")
|
73
|
+
patricia_trie.define_column(column_name, "ShortText")
|
74
|
+
item("groonga: PatriciaTrie") do
|
76
75
|
values.each do |value|
|
77
|
-
|
76
|
+
patricia_trie.set_column_value(value, column_name, value)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
double_array_trie = Groonga::DoubleArrayTrie.create(:name => "DoubleArrayTrie",
|
81
|
+
:key_type => "ShortText")
|
82
|
+
double_array_trie.define_column(column_name, "ShortText")
|
83
|
+
item("groonga: DoubleArrayTrie") do
|
84
|
+
values.each do |value|
|
85
|
+
double_array_trie.set_column_value(value, column_name, value)
|
78
86
|
end
|
79
87
|
end
|
80
88
|
rescue LoadError
|
@@ -83,11 +91,11 @@ end
|
|
83
91
|
begin
|
84
92
|
require 'localmemcache'
|
85
93
|
|
94
|
+
LocalMemCache.drop(:namespace => "write-many-small-items", :force => true)
|
95
|
+
mem_cache = LocalMemCache.new(:namespace => "write-many-small-items")
|
86
96
|
item("Localmemcache: file") do
|
87
|
-
LocalMemCache.drop(:namespace => "write-many-small-items", :force => true)
|
88
|
-
@db = LocalMemCache.new(:namespace => "write-many-small-items")
|
89
97
|
values.each do |value|
|
90
|
-
|
98
|
+
mem_cache[value] = value
|
91
99
|
end
|
92
100
|
end
|
93
101
|
rescue LoadError
|
@@ -96,37 +104,37 @@ end
|
|
96
104
|
begin
|
97
105
|
require 'tokyocabinet'
|
98
106
|
|
107
|
+
tc_hash_memory = TokyoCabinet::ADB::new
|
108
|
+
tc_hash_memory.open("*#bnum=#{n}#mode=wct#xmsiz=0")
|
99
109
|
item("TC: Hash: memory") do
|
100
|
-
@db = TokyoCabinet::ADB::new
|
101
|
-
@db.open("*#bnum=#{n}#mode=wct#xmsiz=0")
|
102
110
|
values.each do |value|
|
103
|
-
|
111
|
+
tc_hash_memory.put(value, value)
|
104
112
|
end
|
105
113
|
end
|
106
114
|
|
115
|
+
tc_tree_memory = TokyoCabinet::ADB::new
|
116
|
+
tc_tree_memory.open("+#bnum=#{n}#mode=wct#xmsiz=0")
|
107
117
|
item("TC: Tree: memory") do
|
108
|
-
@db = TokyoCabinet::ADB::new
|
109
|
-
@db.open("+#bnum=#{n}#mode=wct#xmsiz=0")
|
110
118
|
values.each do |value|
|
111
|
-
|
119
|
+
tc_tree_memory.put(value, value)
|
112
120
|
end
|
113
121
|
end
|
114
122
|
|
115
123
|
hash_file = Tempfile.new(["tc-hash", ".tch"])
|
124
|
+
tc_hash_file = TokyoCabinet::ADB::new
|
125
|
+
tc_hash_file.open("#{hash_file.path}#bnum=#{n}#mode=wct#xmsiz=0")
|
116
126
|
item("TC: Hash: file") do
|
117
|
-
@db = TokyoCabinet::ADB::new
|
118
|
-
@db.open("#{hash_file.path}#bnum=#{n}#mode=wct#xmsiz=0")
|
119
127
|
values.each do |value|
|
120
|
-
|
128
|
+
tc_hash_file.put(value, value)
|
121
129
|
end
|
122
130
|
end
|
123
131
|
|
124
132
|
tree_file = Tempfile.new(["tc-tree", ".tcb"])
|
133
|
+
tc_tree_file = TokyoCabinet::ADB::new
|
134
|
+
tc_tree_file.open("#{tree_file.path}#bnum=#{n}#mode=wct#xmsiz=0")
|
125
135
|
item("TC: Tree: file") do
|
126
|
-
@db = TokyoCabinet::ADB::new
|
127
|
-
@db.open("#{tree_file.path}#bnum=#{n}#mode=wct#xmsiz=0")
|
128
136
|
values.each do |value|
|
129
|
-
|
137
|
+
tc_tree_file.put(value, value)
|
130
138
|
end
|
131
139
|
end
|
132
140
|
rescue LoadError
|