droonga-engine 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/Rakefile +6 -0
- data/bin/droonga-engine-absorb-data +14 -14
- data/bin/droonga-engine-catalog-generate +24 -12
- data/bin/droonga-engine-catalog-modify +13 -7
- data/bin/droonga-engine-join +8 -8
- data/bin/droonga-engine-set-role +1 -1
- data/bin/droonga-engine-unjoin +2 -2
- data/lib/droonga/address.rb +3 -0
- data/lib/droonga/cluster.rb +16 -10
- data/lib/droonga/command/droonga_engine_service.rb +5 -2
- data/lib/droonga/command/remote_command_base.rb +3 -3
- data/lib/droonga/distributed_command_planner.rb +11 -1
- data/lib/droonga/engine.rb +12 -11
- data/lib/droonga/engine/version.rb +2 -2
- data/lib/droonga/engine_node.rb +28 -28
- data/lib/droonga/engine_state.rb +41 -36
- data/lib/droonga/forward_buffer.rb +21 -10
- data/lib/droonga/node_role.rb +2 -0
- data/lib/droonga/plugins/groonga/select.rb +3 -0
- data/lib/droonga/plugins/search.rb +3 -1
- data/lib/droonga/plugins/search/distributed_search_planner.rb +17 -5
- data/lib/droonga/plugins/system/statistics.rb +1 -0
- data/lib/droonga/searcher.rb +13 -4
- data/test/command/config/single_slice/catalog.json +38 -0
- data/test/command/config/single_slice/droonga-engine.yaml +4 -0
- data/test/command/run-test.rb +3 -2
- data/test/command/suite/catalog/fetch.expected.single_slice +50 -0
- data/test/command/suite/dump/column/index.expected.single_slice +86 -0
- data/test/command/suite/dump/column/scalar.expected.single_slice +52 -0
- data/test/command/suite/dump/column/vector.expected.single_slice +55 -0
- data/test/command/suite/dump/record/scalar.expected.single_slice +52 -0
- data/test/command/suite/dump/record/vector/reference.expected.single_slice +117 -0
- data/test/command/suite/dump/table/array.expected.single_slice +39 -0
- data/test/command/suite/dump/table/double_array_trie.expected.single_slice +40 -0
- data/test/command/suite/dump/table/hash.expected.single_slice +40 -0
- data/test/command/suite/dump/table/patricia_trie.expected.single_slice +40 -0
- data/test/command/suite/message/error/missing-dataset.test +3 -0
- data/test/command/suite/search/condition/query/nonexistent_column.expected.single_slice +26 -0
- data/test/command/suite/search/condition/query/syntax_error.expected.single_slice +26 -0
- data/test/command/suite/search/error/unknown-source.expected.single_slice +28 -0
- data/test/command/suite/search/output/attributes/invalid.expected.single_slice +24 -0
- data/test/command/suite/system/absorb-data/records.catalog.json.single_slice +44 -0
- data/test/command/suite/system/absorb-data/records.expected.single_slice +32 -0
- data/test/command/suite/system/statistics/object/count/per-volume/empty.test +1 -0
- data/test/command/suite/system/statistics/object/count/record.expected.single_slice +11 -0
- data/test/command/suite/system/statistics/object/count/schema.expected.single_slice +11 -0
- data/test/unit/catalog/test_generator.rb +3 -2
- data/test/unit/helper.rb +2 -1
- data/test/unit/helper/stub_serf.rb +28 -0
- data/test/unit/plugins/system/statistics/test_object_count.rb +135 -0
- data/test/unit/plugins/system/statistics/test_object_count_per_volume.rb +149 -0
- data/test/unit/plugins/test_basic.rb +0 -406
- data/test/unit/test_address.rb +111 -10
- data/test/unit/test_cluster.rb +232 -0
- data/test/unit/test_differ.rb +49 -0
- data/test/unit/test_engine_node.rb +556 -0
- data/test/unit/test_engine_state.rb +151 -0
- data/test/unit/test_forward_buffer.rb +106 -0
- data/test/unit/test_node_name.rb +160 -0
- data/test/unit/test_node_role.rb +53 -0
- data/test/unit/test_reducer.rb +525 -0
- metadata +111 -49
@@ -0,0 +1,135 @@
|
|
1
|
+
# Copyright (C) 2015 Droonga Project
|
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
|
+
require "droonga/plugins/system"
|
17
|
+
|
18
|
+
class SystemStatisticsObjectCountHandlerTest < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
setup_database
|
21
|
+
setup_handler
|
22
|
+
|
23
|
+
Groonga::Schema.define do |schema|
|
24
|
+
schema.create_table("Books", :type => :hash)
|
25
|
+
schema.change_table("Books") do |table|
|
26
|
+
table.column("title", "ShortText", :type => :scalar)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
Groonga::Context.default["Books"].add("sample")
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
teardown_handler
|
34
|
+
teardown_database
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def setup_handler
|
39
|
+
@worker = StubWorker.new
|
40
|
+
@messenger = Droonga::Test::StubHandlerMessenger.new
|
41
|
+
@loop = nil
|
42
|
+
handler_params = {
|
43
|
+
:name => "name",
|
44
|
+
:label => "label",
|
45
|
+
:context => @worker.context,
|
46
|
+
:messenger => @messenger,
|
47
|
+
:loop => @loop,
|
48
|
+
}
|
49
|
+
@handler = Droonga::Plugins::System::StatisticsObjectCountHandler.new(handler_params)
|
50
|
+
end
|
51
|
+
|
52
|
+
def teardown_handler
|
53
|
+
@handler = nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def process(request)
|
57
|
+
message = Droonga::Test::StubHandlerMessage.new(request)
|
58
|
+
@handler.handle(message)
|
59
|
+
end
|
60
|
+
|
61
|
+
public
|
62
|
+
data(
|
63
|
+
:all => {
|
64
|
+
:request => {
|
65
|
+
"output" => [
|
66
|
+
"tables",
|
67
|
+
"columns",
|
68
|
+
"records",
|
69
|
+
"total",
|
70
|
+
],
|
71
|
+
},
|
72
|
+
:expected => {
|
73
|
+
"tables" => 1,
|
74
|
+
"columns" => 1,
|
75
|
+
"records" => 1,
|
76
|
+
"total" => 3,
|
77
|
+
},
|
78
|
+
},
|
79
|
+
:tables => {
|
80
|
+
:request => {
|
81
|
+
"output" => [
|
82
|
+
"tables",
|
83
|
+
],
|
84
|
+
},
|
85
|
+
:expected => {
|
86
|
+
"tables" => 1,
|
87
|
+
},
|
88
|
+
},
|
89
|
+
:columns => {
|
90
|
+
:request => {
|
91
|
+
"output" => [
|
92
|
+
"columns",
|
93
|
+
],
|
94
|
+
},
|
95
|
+
:expected => {
|
96
|
+
"columns" => 1,
|
97
|
+
},
|
98
|
+
},
|
99
|
+
:records => {
|
100
|
+
:request => {
|
101
|
+
"output" => [
|
102
|
+
"records",
|
103
|
+
],
|
104
|
+
},
|
105
|
+
:expected => {
|
106
|
+
"records" => 1,
|
107
|
+
},
|
108
|
+
},
|
109
|
+
:total => {
|
110
|
+
:request => {
|
111
|
+
"output" => [
|
112
|
+
"total",
|
113
|
+
],
|
114
|
+
},
|
115
|
+
:expected => {
|
116
|
+
"total" => 3,
|
117
|
+
},
|
118
|
+
},
|
119
|
+
:nothing => {
|
120
|
+
:request => {
|
121
|
+
"output" => [],
|
122
|
+
},
|
123
|
+
:expected => {},
|
124
|
+
},
|
125
|
+
:no_parameter => {
|
126
|
+
:request => {},
|
127
|
+
:expected => {},
|
128
|
+
},
|
129
|
+
)
|
130
|
+
def test_output(data)
|
131
|
+
request = data[:request]
|
132
|
+
response = process(request)
|
133
|
+
assert_equal(data[:expected], response)
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# Copyright (C) 2015 Droonga Project
|
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
|
+
require "droonga/plugins/system"
|
17
|
+
|
18
|
+
class SystemStatisticsObjectCountPerVolumeHandlerTest < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
setup_database
|
21
|
+
setup_handler
|
22
|
+
|
23
|
+
Groonga::Schema.define do |schema|
|
24
|
+
schema.create_table("Books", :type => :hash)
|
25
|
+
schema.change_table("Books") do |table|
|
26
|
+
table.column("title", "ShortText", :type => :scalar)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
Groonga::Context.default["Books"].add("sample")
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
teardown_handler
|
34
|
+
teardown_database
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def setup_handler
|
39
|
+
@worker = StubWorker.new
|
40
|
+
@messenger = Droonga::Test::StubHandlerMessenger.new
|
41
|
+
@loop = nil
|
42
|
+
handler_params = {
|
43
|
+
:name => "name",
|
44
|
+
:label => "label",
|
45
|
+
:context => @worker.context,
|
46
|
+
:messenger => @messenger,
|
47
|
+
:loop => @loop,
|
48
|
+
}
|
49
|
+
@handler = Droonga::Plugins::System::StatisticsObjectCountPerVolumeHandler.new(handler_params)
|
50
|
+
end
|
51
|
+
|
52
|
+
def teardown_handler
|
53
|
+
@handler = nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def process(request)
|
57
|
+
message = Droonga::Test::StubHandlerMessage.new(request)
|
58
|
+
@handler.handle(message)
|
59
|
+
end
|
60
|
+
|
61
|
+
public
|
62
|
+
data(
|
63
|
+
:all => {
|
64
|
+
:request => {
|
65
|
+
"output" => [
|
66
|
+
"tables",
|
67
|
+
"columns",
|
68
|
+
"records",
|
69
|
+
"total",
|
70
|
+
],
|
71
|
+
},
|
72
|
+
:expected => {
|
73
|
+
"label" => {
|
74
|
+
"tables" => 1,
|
75
|
+
"columns" => 1,
|
76
|
+
"records" => 1,
|
77
|
+
"total" => 3,
|
78
|
+
},
|
79
|
+
},
|
80
|
+
},
|
81
|
+
:tables => {
|
82
|
+
:request => {
|
83
|
+
"output" => [
|
84
|
+
"tables",
|
85
|
+
],
|
86
|
+
},
|
87
|
+
:expected => {
|
88
|
+
"label" => {
|
89
|
+
"tables" => 1,
|
90
|
+
},
|
91
|
+
},
|
92
|
+
},
|
93
|
+
:columns => {
|
94
|
+
:request => {
|
95
|
+
"output" => [
|
96
|
+
"columns",
|
97
|
+
],
|
98
|
+
},
|
99
|
+
:expected => {
|
100
|
+
"label" => {
|
101
|
+
"columns" => 1,
|
102
|
+
},
|
103
|
+
},
|
104
|
+
},
|
105
|
+
:records => {
|
106
|
+
:request => {
|
107
|
+
"output" => [
|
108
|
+
"records",
|
109
|
+
],
|
110
|
+
},
|
111
|
+
:expected => {
|
112
|
+
"label" => {
|
113
|
+
"records" => 1,
|
114
|
+
},
|
115
|
+
},
|
116
|
+
},
|
117
|
+
:total => {
|
118
|
+
:request => {
|
119
|
+
"output" => [
|
120
|
+
"total",
|
121
|
+
],
|
122
|
+
},
|
123
|
+
:expected => {
|
124
|
+
"label" => {
|
125
|
+
"total" => 3,
|
126
|
+
},
|
127
|
+
},
|
128
|
+
},
|
129
|
+
:nothing => {
|
130
|
+
:request => {
|
131
|
+
"output" => [],
|
132
|
+
},
|
133
|
+
:expected => {
|
134
|
+
"label" => {},
|
135
|
+
},
|
136
|
+
},
|
137
|
+
:no_parameter => {
|
138
|
+
:request => {},
|
139
|
+
:expected => {
|
140
|
+
"label" => {},
|
141
|
+
},
|
142
|
+
},
|
143
|
+
)
|
144
|
+
def test_output(data)
|
145
|
+
request = data[:request]
|
146
|
+
response = process(request)
|
147
|
+
assert_equal(data[:expected], response)
|
148
|
+
end
|
149
|
+
end
|
@@ -24,11 +24,6 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
24
24
|
teardown_database
|
25
25
|
end
|
26
26
|
|
27
|
-
private
|
28
|
-
def create_record(*columns)
|
29
|
-
columns
|
30
|
-
end
|
31
|
-
|
32
27
|
def run_collector(collector, message)
|
33
28
|
collector_message = Droonga::CollectorMessage.new(message)
|
34
29
|
collector.collect(collector_message)
|
@@ -45,12 +40,6 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
45
40
|
run_collector(collector, message)
|
46
41
|
end
|
47
42
|
|
48
|
-
class << self
|
49
|
-
def create_record(*columns)
|
50
|
-
columns
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
43
|
class IOTest < self
|
55
44
|
data(
|
56
45
|
:simple_mapping => {
|
@@ -112,399 +101,4 @@ class BasicCollectorTest < Test::Unit::TestCase
|
|
112
101
|
reduce(request))
|
113
102
|
end
|
114
103
|
end
|
115
|
-
|
116
|
-
# TODO: Split file
|
117
|
-
class ReducerTest < self
|
118
|
-
def reduce_value(deal, left_value, right_value)
|
119
|
-
reducer = Droonga::Reducer.new(deal)
|
120
|
-
reducer.reduce(left_value, right_value)
|
121
|
-
end
|
122
|
-
|
123
|
-
data(
|
124
|
-
:int => {
|
125
|
-
:expected => 1.5,
|
126
|
-
:left => 1,
|
127
|
-
:right => 2,
|
128
|
-
},
|
129
|
-
:float => {
|
130
|
-
:expected => 1.5,
|
131
|
-
:left => 1.0,
|
132
|
-
:right => 2.0,
|
133
|
-
},
|
134
|
-
)
|
135
|
-
def test_average(data)
|
136
|
-
reduced = reduce_value({ "type" => "average" },
|
137
|
-
data[:left],
|
138
|
-
data[:right])
|
139
|
-
assert_equal(data[:expected], reduced)
|
140
|
-
end
|
141
|
-
|
142
|
-
data(
|
143
|
-
:true_and_false => {
|
144
|
-
:expected => false,
|
145
|
-
:left => true,
|
146
|
-
:right => false,
|
147
|
-
},
|
148
|
-
:false_and_true => {
|
149
|
-
:expected => false,
|
150
|
-
:left => false,
|
151
|
-
:right => true,
|
152
|
-
},
|
153
|
-
:both_true => {
|
154
|
-
:expected => true,
|
155
|
-
:left => true,
|
156
|
-
:right => true,
|
157
|
-
},
|
158
|
-
:both_false => {
|
159
|
-
:expected => false,
|
160
|
-
:left => false,
|
161
|
-
:right => false,
|
162
|
-
},
|
163
|
-
)
|
164
|
-
def test_and(data)
|
165
|
-
reduced = reduce_value({ "type" => "and" },
|
166
|
-
data[:left],
|
167
|
-
data[:right])
|
168
|
-
assert_equal(data[:expected], reduced)
|
169
|
-
end
|
170
|
-
|
171
|
-
data(
|
172
|
-
:true_and_false => {
|
173
|
-
:expected => true,
|
174
|
-
:left => true,
|
175
|
-
:right => false,
|
176
|
-
},
|
177
|
-
:false_and_true => {
|
178
|
-
:expected => true,
|
179
|
-
:left => false,
|
180
|
-
:right => true,
|
181
|
-
},
|
182
|
-
:both_true => {
|
183
|
-
:expected => true,
|
184
|
-
:left => true,
|
185
|
-
:right => true,
|
186
|
-
},
|
187
|
-
:both_false => {
|
188
|
-
:expected => false,
|
189
|
-
:left => false,
|
190
|
-
:right => false,
|
191
|
-
},
|
192
|
-
)
|
193
|
-
def test_or(data)
|
194
|
-
reduced = reduce_value({ "type" => "or" },
|
195
|
-
data[:left],
|
196
|
-
data[:right])
|
197
|
-
assert_equal(data[:expected], reduced)
|
198
|
-
end
|
199
|
-
|
200
|
-
data(
|
201
|
-
:numeric_values => {
|
202
|
-
:expected => 3,
|
203
|
-
:left => 1,
|
204
|
-
:right => 2,
|
205
|
-
},
|
206
|
-
:numeric_key_records => {
|
207
|
-
:expected => [
|
208
|
-
create_record(1),
|
209
|
-
create_record(2),
|
210
|
-
create_record(3),
|
211
|
-
create_record(4),
|
212
|
-
create_record(5),
|
213
|
-
create_record(6),
|
214
|
-
],
|
215
|
-
:left => [
|
216
|
-
create_record(1),
|
217
|
-
create_record(2),
|
218
|
-
create_record(3),
|
219
|
-
],
|
220
|
-
:right => [
|
221
|
-
create_record(4),
|
222
|
-
create_record(5),
|
223
|
-
create_record(6),
|
224
|
-
],
|
225
|
-
},
|
226
|
-
:string_key_records => {
|
227
|
-
:expected => [
|
228
|
-
create_record("a"),
|
229
|
-
create_record("b"),
|
230
|
-
create_record("c"),
|
231
|
-
create_record("d"),
|
232
|
-
create_record("e"),
|
233
|
-
create_record("f"),
|
234
|
-
],
|
235
|
-
:left => [
|
236
|
-
create_record("a"),
|
237
|
-
create_record("b"),
|
238
|
-
create_record("c"),
|
239
|
-
],
|
240
|
-
:right => [
|
241
|
-
create_record("d"),
|
242
|
-
create_record("e"),
|
243
|
-
create_record("f"),
|
244
|
-
],
|
245
|
-
},
|
246
|
-
:numeric_values_with_limit => {
|
247
|
-
:expected => 3,
|
248
|
-
:left => 1,
|
249
|
-
:right => 2,
|
250
|
-
:limit => 2,
|
251
|
-
},
|
252
|
-
:numeric_key_records_with_limit => {
|
253
|
-
:expected => [
|
254
|
-
create_record(1),
|
255
|
-
create_record(2),
|
256
|
-
],
|
257
|
-
:left => [
|
258
|
-
create_record(1),
|
259
|
-
create_record(2),
|
260
|
-
create_record(3),
|
261
|
-
],
|
262
|
-
:right => [
|
263
|
-
create_record(4),
|
264
|
-
create_record(5),
|
265
|
-
create_record(6),
|
266
|
-
],
|
267
|
-
:limit => 2,
|
268
|
-
},
|
269
|
-
:string_key_records_with_limit => {
|
270
|
-
:expected => [
|
271
|
-
create_record("a"),
|
272
|
-
create_record("b"),
|
273
|
-
],
|
274
|
-
:left => [
|
275
|
-
create_record("a"),
|
276
|
-
create_record("b"),
|
277
|
-
create_record("c"),
|
278
|
-
],
|
279
|
-
:right => [
|
280
|
-
create_record("d"),
|
281
|
-
create_record("e"),
|
282
|
-
create_record("f"),
|
283
|
-
],
|
284
|
-
:limit => 2,
|
285
|
-
},
|
286
|
-
)
|
287
|
-
def test_sum(data)
|
288
|
-
reduced = reduce_value({ "type" => "sum",
|
289
|
-
"limit" => data[:limit] || -1 },
|
290
|
-
data[:left],
|
291
|
-
data[:right])
|
292
|
-
assert_equal(data[:expected], reduced)
|
293
|
-
end
|
294
|
-
|
295
|
-
data(
|
296
|
-
:numeric_key_records => {
|
297
|
-
:expected => [
|
298
|
-
create_record(1),
|
299
|
-
create_record(2),
|
300
|
-
create_record(3),
|
301
|
-
create_record(4),
|
302
|
-
create_record(5),
|
303
|
-
create_record(6),
|
304
|
-
],
|
305
|
-
:left => [
|
306
|
-
create_record(1),
|
307
|
-
create_record(3),
|
308
|
-
create_record(5),
|
309
|
-
],
|
310
|
-
:right => [
|
311
|
-
create_record(2),
|
312
|
-
create_record(4),
|
313
|
-
create_record(6),
|
314
|
-
],
|
315
|
-
},
|
316
|
-
:string_key_records => {
|
317
|
-
:expected => [
|
318
|
-
create_record("a"),
|
319
|
-
create_record("b"),
|
320
|
-
create_record("c"),
|
321
|
-
create_record("d"),
|
322
|
-
create_record("e"),
|
323
|
-
create_record("f"),
|
324
|
-
],
|
325
|
-
:left => [
|
326
|
-
create_record("a"),
|
327
|
-
create_record("c"),
|
328
|
-
create_record("e"),
|
329
|
-
],
|
330
|
-
:right => [
|
331
|
-
create_record("b"),
|
332
|
-
create_record("d"),
|
333
|
-
create_record("f"),
|
334
|
-
],
|
335
|
-
},
|
336
|
-
:numeric_key_records_with_limit => {
|
337
|
-
:expected => [
|
338
|
-
create_record(1),
|
339
|
-
create_record(2),
|
340
|
-
],
|
341
|
-
:left => [
|
342
|
-
create_record(1),
|
343
|
-
create_record(3),
|
344
|
-
create_record(5),
|
345
|
-
],
|
346
|
-
:right => [
|
347
|
-
create_record(2),
|
348
|
-
create_record(4),
|
349
|
-
create_record(6),
|
350
|
-
],
|
351
|
-
:limit => 2,
|
352
|
-
},
|
353
|
-
:string_key_records_with_limit => {
|
354
|
-
:expected => [
|
355
|
-
create_record("a"),
|
356
|
-
create_record("b"),
|
357
|
-
],
|
358
|
-
:left => [
|
359
|
-
create_record("a"),
|
360
|
-
create_record("c"),
|
361
|
-
create_record("e"),
|
362
|
-
],
|
363
|
-
:right => [
|
364
|
-
create_record("b"),
|
365
|
-
create_record("d"),
|
366
|
-
create_record("f"),
|
367
|
-
],
|
368
|
-
:limit => 2,
|
369
|
-
},
|
370
|
-
)
|
371
|
-
def test_sort(data)
|
372
|
-
reduced = reduce_value({
|
373
|
-
"type" => "sort",
|
374
|
-
"operators" => [
|
375
|
-
{ "column" => 0, "operator" => "<" },
|
376
|
-
],
|
377
|
-
"limit" => data[:limit] || -1,
|
378
|
-
},
|
379
|
-
data[:left],
|
380
|
-
data[:right])
|
381
|
-
assert_equal(data[:expected], reduced)
|
382
|
-
end
|
383
|
-
end
|
384
|
-
|
385
|
-
# TODO: Split file
|
386
|
-
class MergeTest < self
|
387
|
-
def reduce_value(deal, left_value, right_value)
|
388
|
-
reducer = Droonga::Reducer.new(deal)
|
389
|
-
reducer.reduce(left_value, right_value)
|
390
|
-
end
|
391
|
-
|
392
|
-
def test_grouped
|
393
|
-
expected = [
|
394
|
-
[
|
395
|
-
"group3",
|
396
|
-
30,
|
397
|
-
[
|
398
|
-
create_record("A"),
|
399
|
-
create_record("B"),
|
400
|
-
create_record("C"),
|
401
|
-
],
|
402
|
-
],
|
403
|
-
[
|
404
|
-
"group1",
|
405
|
-
40,
|
406
|
-
[
|
407
|
-
create_record(2),
|
408
|
-
create_record(4),
|
409
|
-
create_record(6),
|
410
|
-
create_record(1),
|
411
|
-
create_record(3),
|
412
|
-
create_record(5),
|
413
|
-
],
|
414
|
-
],
|
415
|
-
[
|
416
|
-
"group4",
|
417
|
-
50,
|
418
|
-
[
|
419
|
-
create_record("D"),
|
420
|
-
create_record("E"),
|
421
|
-
create_record("F"),
|
422
|
-
],
|
423
|
-
],
|
424
|
-
[
|
425
|
-
"group2",
|
426
|
-
60,
|
427
|
-
[
|
428
|
-
create_record("b"),
|
429
|
-
create_record("d"),
|
430
|
-
create_record("f"),
|
431
|
-
create_record("a"),
|
432
|
-
create_record("c"),
|
433
|
-
create_record("e"),
|
434
|
-
],
|
435
|
-
],
|
436
|
-
]
|
437
|
-
|
438
|
-
left = [
|
439
|
-
[
|
440
|
-
"group1",
|
441
|
-
10,
|
442
|
-
[
|
443
|
-
create_record(1),
|
444
|
-
create_record(3),
|
445
|
-
create_record(5),
|
446
|
-
],
|
447
|
-
],
|
448
|
-
[
|
449
|
-
"group2",
|
450
|
-
20,
|
451
|
-
[
|
452
|
-
create_record("a"),
|
453
|
-
create_record("c"),
|
454
|
-
create_record("e"),
|
455
|
-
],
|
456
|
-
],
|
457
|
-
[
|
458
|
-
"group3",
|
459
|
-
30,
|
460
|
-
[
|
461
|
-
create_record("A"),
|
462
|
-
create_record("B"),
|
463
|
-
create_record("C"),
|
464
|
-
],
|
465
|
-
],
|
466
|
-
]
|
467
|
-
right = [
|
468
|
-
[
|
469
|
-
"group1",
|
470
|
-
30,
|
471
|
-
[
|
472
|
-
create_record(2),
|
473
|
-
create_record(4),
|
474
|
-
create_record(6),
|
475
|
-
],
|
476
|
-
],
|
477
|
-
[
|
478
|
-
"group2",
|
479
|
-
40,
|
480
|
-
[
|
481
|
-
create_record("b"),
|
482
|
-
create_record("d"),
|
483
|
-
create_record("f"),
|
484
|
-
],
|
485
|
-
],
|
486
|
-
[
|
487
|
-
"group4",
|
488
|
-
50,
|
489
|
-
[
|
490
|
-
create_record("D"),
|
491
|
-
create_record("E"),
|
492
|
-
create_record("F"),
|
493
|
-
],
|
494
|
-
],
|
495
|
-
]
|
496
|
-
|
497
|
-
reduced = reduce_value({
|
498
|
-
"type" => "sort",
|
499
|
-
"operators" => [
|
500
|
-
{ "column" => 1, "operator" => "<" },
|
501
|
-
],
|
502
|
-
"key_column" => 0,
|
503
|
-
"limit" => -1,
|
504
|
-
},
|
505
|
-
left,
|
506
|
-
right)
|
507
|
-
assert_equal(expected, reduced)
|
508
|
-
end
|
509
|
-
end
|
510
104
|
end
|