fluent-plugin-droonga 0.9.0 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +8 -1
- data/fluent-plugin-droonga.gemspec +2 -2
- data/lib/droonga/adapter.rb +39 -0
- data/lib/droonga/adapter_runner.rb +99 -0
- data/lib/droonga/catalog/base.rb +11 -11
- data/lib/droonga/catalog/dataset.rb +54 -0
- data/lib/droonga/catalog/version1.rb +1 -1
- data/lib/droonga/collector.rb +5 -7
- data/lib/droonga/collector_plugin.rb +7 -7
- data/lib/droonga/command.rb +36 -0
- data/lib/droonga/{plugin/input_adapter/crud.rb → command_repository.rb} +14 -8
- data/lib/droonga/dispatcher.rb +86 -54
- data/lib/droonga/distributed_command_planner.rb +183 -0
- data/lib/droonga/distributor.rb +43 -17
- data/lib/droonga/handler.rb +13 -72
- data/lib/droonga/handler_message.rb +5 -5
- data/lib/droonga/handler_messenger.rb +4 -1
- data/lib/droonga/handler_plugin.rb +2 -2
- data/lib/droonga/handler_runner.rb +104 -0
- data/lib/droonga/input_message.rb +4 -4
- data/lib/droonga/legacy_pluggable.rb +66 -0
- data/lib/droonga/{input_adapter.rb → legacy_plugin.rb} +27 -22
- data/lib/droonga/{plugin_repository.rb → legacy_plugin_repository.rb} +2 -4
- data/lib/droonga/message_matcher.rb +101 -0
- data/lib/droonga/{input_adapter_plugin.rb → planner.rb} +14 -10
- data/lib/droonga/planner_plugin.rb +54 -0
- data/lib/droonga/pluggable.rb +9 -45
- data/lib/droonga/plugin.rb +9 -33
- data/lib/droonga/plugin/collector/basic.rb +2 -0
- data/lib/droonga/plugin/collector/search.rb +31 -37
- data/lib/droonga/plugin/{handler/groonga/table_remove.rb → metadata/adapter_message.rb} +23 -18
- data/lib/droonga/plugin/{handler/search.rb → metadata/handler_action.rb} +19 -15
- data/lib/droonga/plugin/metadata/input_message.rb +39 -0
- data/lib/droonga/plugin/planner/crud.rb +49 -0
- data/lib/droonga/plugin/{distributor → planner}/distributed_search_planner.rb +62 -70
- data/lib/droonga/plugin/{distributor → planner}/groonga.rb +11 -32
- data/lib/droonga/plugin/{distributor → planner}/search.rb +5 -5
- data/lib/droonga/plugin/{distributor → planner}/watch.rb +15 -6
- data/lib/droonga/plugin_loader.rb +10 -0
- data/lib/droonga/plugin_registerable.rb +34 -10
- data/lib/droonga/plugin_registry.rb +58 -0
- data/lib/droonga/plugins/crud.rb +124 -0
- data/lib/droonga/plugins/error.rb +50 -0
- data/lib/droonga/{output_adapter_plugin.rb → plugins/groonga.rb} +9 -13
- data/lib/droonga/plugins/groonga/column_create.rb +123 -0
- data/lib/droonga/plugins/groonga/generic_command.rb +65 -0
- data/lib/droonga/{plugin/output_adapter/groonga.rb → plugins/groonga/generic_response.rb} +16 -15
- data/lib/droonga/plugins/groonga/select.rb +124 -0
- data/lib/droonga/plugins/groonga/table_create.rb +106 -0
- data/lib/droonga/plugins/groonga/table_remove.rb +57 -0
- data/lib/droonga/plugins/search.rb +40 -0
- data/lib/droonga/plugins/watch.rb +156 -0
- data/lib/droonga/processor.rb +8 -10
- data/lib/droonga/searcher.rb +14 -4
- data/lib/droonga/searcher/mecab_filter.rb +67 -0
- data/lib/droonga/session.rb +5 -5
- data/lib/droonga/test.rb +1 -1
- data/lib/droonga/test/stub_handler_message.rb +1 -1
- data/lib/droonga/test/{stub_distributor.rb → stub_planner.rb} +1 -1
- data/lib/droonga/worker.rb +7 -8
- data/lib/fluent/plugin/out_droonga.rb +0 -1
- data/sample/cluster/catalog.json +2 -4
- data/sample/mecab_filter/data.grn +7 -0
- data/sample/mecab_filter/ddl.grn +7 -0
- data/sample/mecab_filter/search_with_mecab_filter.json +21 -0
- data/sample/mecab_filter/search_without_mecab_filter.json +21 -0
- data/test/command/config/default/catalog.json +2 -5
- data/test/command/suite/search/error/no-query.expected +13 -0
- data/test/command/suite/search/error/no-query.test +7 -0
- data/test/command/suite/search/error/unknown-source.expected +26 -0
- data/test/command/suite/watch/subscribe.expected +3 -3
- data/test/command/suite/watch/unsubscribe.expected +3 -3
- data/test/unit/catalog/test_dataset.rb +385 -0
- data/test/unit/catalog/test_version1.rb +111 -45
- data/test/unit/fixtures/catalog/version1.json +0 -3
- data/test/unit/helper.rb +2 -1
- data/test/unit/helper/distributed_search_planner_helper.rb +83 -0
- data/test/unit/plugin/collector/test_basic.rb +233 -376
- data/test/unit/plugin/collector/test_search.rb +8 -17
- data/test/unit/plugin/planner/search_planner/test_basic.rb +120 -0
- data/test/unit/plugin/planner/search_planner/test_group_by.rb +573 -0
- data/test/unit/plugin/planner/search_planner/test_output.rb +388 -0
- data/test/unit/plugin/planner/search_planner/test_sort_by.rb +938 -0
- data/test/unit/plugin/{distributor → planner}/test_search.rb +20 -75
- data/test/unit/{plugin/handler → plugins/crud}/test_add.rb +11 -11
- data/test/unit/plugins/groonga/select/test_adapter_input.rb +213 -0
- data/test/unit/{plugin/output_adapter/groonga/test_select.rb → plugins/groonga/select/test_adapter_output.rb} +12 -13
- data/test/unit/{plugin/handler → plugins}/groonga/test_column_create.rb +20 -5
- data/test/unit/{plugin/handler → plugins}/groonga/test_table_create.rb +5 -0
- data/test/unit/{plugin/handler → plugins}/groonga/test_table_remove.rb +8 -1
- data/test/unit/{plugin/handler → plugins}/test_groonga.rb +5 -5
- data/test/unit/{plugin/handler → plugins}/test_search.rb +21 -5
- data/test/unit/{plugin/handler → plugins}/test_watch.rb +29 -10
- data/{lib/droonga/command_mapper.rb → test/unit/test_command_repository.rb} +16 -22
- data/test/unit/{test_plugin.rb → test_legacy_plugin.rb} +3 -3
- data/test/unit/{test_plugin_repository.rb → test_legacy_plugin_repository.rb} +3 -3
- data/test/unit/test_message_matcher.rb +137 -0
- metadata +86 -66
- data/bin/grn2jsons +0 -82
- data/lib/droonga/distribution_planner.rb +0 -76
- data/lib/droonga/distributor_plugin.rb +0 -95
- data/lib/droonga/output_adapter.rb +0 -53
- data/lib/droonga/plugin/collector/groonga.rb +0 -83
- data/lib/droonga/plugin/distributor/crud.rb +0 -84
- data/lib/droonga/plugin/handler/add.rb +0 -109
- data/lib/droonga/plugin/handler/forward.rb +0 -75
- data/lib/droonga/plugin/handler/groonga.rb +0 -99
- data/lib/droonga/plugin/handler/groonga/column_create.rb +0 -106
- data/lib/droonga/plugin/handler/groonga/table_create.rb +0 -91
- data/lib/droonga/plugin/handler/watch.rb +0 -108
- data/lib/droonga/plugin/input_adapter/groonga.rb +0 -49
- data/lib/droonga/plugin/input_adapter/groonga/select.rb +0 -63
- data/lib/droonga/plugin/output_adapter/crud.rb +0 -51
- data/lib/droonga/plugin/output_adapter/groonga/select.rb +0 -54
- data/lib/groonga_command_converter.rb +0 -143
- data/sample/fluentd.conf +0 -8
- data/test/unit/plugin/distributor/test_search_planner.rb +0 -1102
- data/test/unit/plugin/input_adapter/groonga/test_select.rb +0 -248
- data/test/unit/test_command_mapper.rb +0 -44
- data/test/unit/test_groonga_command_converter.rb +0 -242
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -15,21 +13,27 @@
|
|
15
13
|
# License along with this library; if not, write to the Free Software
|
16
14
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
15
|
|
18
|
-
require "droonga/handler_plugin"
|
19
|
-
require "droonga/searcher"
|
20
|
-
|
21
16
|
module Droonga
|
22
|
-
|
23
|
-
|
17
|
+
module Plugin
|
18
|
+
module Metadata
|
19
|
+
class HandlerAction
|
20
|
+
def initialize(handler_class)
|
21
|
+
@handler_class = handler_class
|
22
|
+
end
|
23
|
+
|
24
|
+
def synchronous?
|
25
|
+
configuration[:synchronous]
|
26
|
+
end
|
27
|
+
|
28
|
+
def synchronous=(boolean)
|
29
|
+
configuration[:synchronous] = boolean
|
30
|
+
end
|
24
31
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
searcher.search(message.request["queries"]).each do |output, value|
|
30
|
-
values[output] = value
|
32
|
+
private
|
33
|
+
def configuration
|
34
|
+
@handler_class.options[:action] ||= {}
|
35
|
+
end
|
31
36
|
end
|
32
|
-
messenger.emit(values)
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (C) 2014 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
module Droonga
|
17
|
+
module Plugin
|
18
|
+
module Metadata
|
19
|
+
class InputMessage
|
20
|
+
def initialize(plugin_class)
|
21
|
+
@plugin_class = plugin_class
|
22
|
+
end
|
23
|
+
|
24
|
+
def type
|
25
|
+
configuration[:type]
|
26
|
+
end
|
27
|
+
|
28
|
+
def type=(type)
|
29
|
+
configuration[:type] = type
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def configuration
|
34
|
+
@plugin_class.options[:message] ||= {}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
+
require "droonga/planner_plugin"
|
19
|
+
|
20
|
+
module Droonga
|
21
|
+
class CRUDPlanner < Droonga::PlannerPlugin
|
22
|
+
repository.register("crud", self)
|
23
|
+
|
24
|
+
command :add
|
25
|
+
def add(message)
|
26
|
+
scatter(message)
|
27
|
+
end
|
28
|
+
|
29
|
+
command :update
|
30
|
+
def update(message)
|
31
|
+
scatter(message)
|
32
|
+
end
|
33
|
+
|
34
|
+
# TODO: What is this?
|
35
|
+
command :reset
|
36
|
+
def reset(message)
|
37
|
+
scatter(message)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def scatter(message)
|
42
|
+
super(message,
|
43
|
+
:key => message["body"]["key"] || rand.to_s,
|
44
|
+
:reduce => {
|
45
|
+
"success" => "and"
|
46
|
+
})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013 Droonga Project
|
3
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -15,27 +15,24 @@
|
|
15
15
|
# License along with this library; if not, write to the Free Software
|
16
16
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
attr_reader :messages
|
18
|
+
require "droonga/searcher"
|
19
|
+
require "droonga/distributed_command_planner"
|
21
20
|
|
21
|
+
module Droonga
|
22
|
+
class DistributedSearchPlanner < DistributedCommandPlanner
|
22
23
|
def initialize(search_request_message)
|
23
|
-
|
24
|
-
@request = @source_message["body"]
|
25
|
-
@queries = @request["queries"]
|
24
|
+
super
|
26
25
|
|
27
|
-
@
|
28
|
-
|
29
|
-
@output_mappers = {}
|
30
|
-
@messages = []
|
26
|
+
@request = @source_message["body"]
|
27
|
+
raise NoQuery.new unless @request
|
31
28
|
|
32
|
-
|
29
|
+
@request = Marshal.load(Marshal.dump(@request))
|
30
|
+
@queries = @request["queries"]
|
33
31
|
end
|
34
32
|
|
35
|
-
|
36
|
-
|
33
|
+
def plan
|
34
|
+
raise Searcher::NoQuery.new if @queries.nil? || @queries.empty?
|
37
35
|
|
38
|
-
def build_messages
|
39
36
|
Searcher::QuerySorter.validate_dependencies(@queries)
|
40
37
|
|
41
38
|
ensure_unifiable!
|
@@ -44,22 +41,21 @@ module Droonga
|
|
44
41
|
transform_query(input_name, query)
|
45
42
|
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@messages.push(searcher)
|
44
|
+
@dataset = @source_message["dataset"] || @request["dataset"]
|
45
|
+
broadcast(:body => @request)
|
46
|
+
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
UNLIMITED = -1
|
52
|
+
|
53
|
+
def reduce_command
|
54
|
+
"search_reduce"
|
55
|
+
end
|
56
|
+
|
57
|
+
def gather_command
|
58
|
+
"search_gather"
|
63
59
|
end
|
64
60
|
|
65
61
|
def ensure_unifiable!
|
@@ -89,28 +85,13 @@ module Droonga
|
|
89
85
|
return
|
90
86
|
end
|
91
87
|
|
92
|
-
@input_names << input_name
|
93
|
-
output_name = input_name + "_reduced"
|
94
|
-
@output_names << output_name
|
95
|
-
|
96
88
|
transformer = QueryTransformer.new(query)
|
97
89
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
},
|
104
|
-
},
|
105
|
-
"inputs" => [input_name], # XXX should be placed in the "body"?
|
106
|
-
"outputs" => [output_name], # XXX should be placed in the "body"?
|
107
|
-
}
|
108
|
-
@messages << reducer
|
109
|
-
|
110
|
-
@output_mappers[output_name] = {
|
111
|
-
"output" => input_name,
|
112
|
-
"elements" => transformer.mappers,
|
113
|
-
}
|
90
|
+
elements = transformer.mappers
|
91
|
+
mapper = {}
|
92
|
+
mapper["elements"] = elements unless elements.empty?
|
93
|
+
reduce(input_name => { :reduce => transformer.reducers,
|
94
|
+
:gather => mapper })
|
114
95
|
end
|
115
96
|
|
116
97
|
class QueryTransformer
|
@@ -130,7 +111,9 @@ module Droonga
|
|
130
111
|
# So we have to override the format and restore it on the gathering
|
131
112
|
# phase.
|
132
113
|
@records_format = @output["format"] || "simple"
|
133
|
-
@output["format"]
|
114
|
+
if @output["format"] && @output["format"] != "simple"
|
115
|
+
@output["format"] = "simple"
|
116
|
+
end
|
134
117
|
|
135
118
|
@sort_keys = @query["sortBy"] || []
|
136
119
|
@sort_keys = @sort_keys["keys"] || [] if @sort_keys.is_a?(Hash)
|
@@ -163,13 +146,22 @@ module Droonga
|
|
163
146
|
@records_offset = final_offset
|
164
147
|
@records_limit = final_limit
|
165
148
|
|
149
|
+
updated_sort_limit = nil
|
150
|
+
updated_output_limit = nil
|
166
151
|
if final_limit == UNLIMITED
|
167
|
-
|
152
|
+
updated_output_limit = UNLIMITED
|
168
153
|
else
|
169
154
|
if rich_sort?
|
170
|
-
|
155
|
+
updated_sort_limit = final_offset + [sort_limit, output_limit].max
|
171
156
|
end
|
172
|
-
|
157
|
+
updated_output_limit = final_offset + final_limit
|
158
|
+
end
|
159
|
+
|
160
|
+
if updated_sort_limit && updated_sort_limit != @query["sortBy"]["limit"]
|
161
|
+
@query["sortBy"]["limit"] = updated_sort_limit
|
162
|
+
end
|
163
|
+
if updated_output_limit && @output["limit"] && updated_output_limit != @output["limit"]
|
164
|
+
@output["limit"] = updated_output_limit
|
173
165
|
end
|
174
166
|
end
|
175
167
|
|
@@ -206,7 +198,7 @@ module Droonga
|
|
206
198
|
end
|
207
199
|
|
208
200
|
def calculate_output_offset!
|
209
|
-
@output["offset"] = 0 if have_records?
|
201
|
+
@output["offset"] = 0 if have_records? && @output["offset"]
|
210
202
|
end
|
211
203
|
|
212
204
|
def final_offset
|
@@ -249,7 +241,6 @@ module Droonga
|
|
249
241
|
@query["sortBy"]["limit"] = -1 if @query["sortBy"].is_a?(Hash)
|
250
242
|
@output["limit"] = -1
|
251
243
|
mapper = {
|
252
|
-
"type" => "count",
|
253
244
|
"target" => "records",
|
254
245
|
}
|
255
246
|
unless @output["elements"].include?("records")
|
@@ -274,14 +265,15 @@ module Droonga
|
|
274
265
|
|
275
266
|
@reducers["records"] = build_records_reducer
|
276
267
|
|
277
|
-
mapper = {
|
278
|
-
|
279
|
-
"
|
280
|
-
"
|
281
|
-
"
|
282
|
-
"
|
283
|
-
|
284
|
-
|
268
|
+
mapper = {}
|
269
|
+
if @output_records
|
270
|
+
mapper["format"] = @records_format unless @records_format == "simple"
|
271
|
+
mapper["attributes"] = final_attributes unless final_attributes.empty?
|
272
|
+
mapper["offset"] = @records_offset unless @records_offset.zero?
|
273
|
+
mapper["limit"] = @records_limit unless @records_limit.zero?
|
274
|
+
else
|
275
|
+
mapper["no_output"] = true
|
276
|
+
end
|
285
277
|
@mappers["records"] = mapper
|
286
278
|
end
|
287
279
|
|
@@ -303,7 +295,7 @@ module Droonga
|
|
303
295
|
def update_output_attributes!
|
304
296
|
@output["attributes"] = array_style_attributes
|
305
297
|
@output["attributes"] += sort_attribute_names
|
306
|
-
if unifiable? &&
|
298
|
+
if unifiable? && !source_column_names.include?("_key")
|
307
299
|
@output["attributes"] << "_key"
|
308
300
|
end
|
309
301
|
end
|
@@ -316,7 +308,7 @@ module Droonga
|
|
316
308
|
case attribute
|
317
309
|
when String
|
318
310
|
{
|
319
|
-
"label"
|
311
|
+
"label" => key,
|
320
312
|
"source" => attribute,
|
321
313
|
}
|
322
314
|
when Hash
|
@@ -365,7 +357,7 @@ module Droonga
|
|
365
357
|
DESCENDING_OPERATOR = ">"
|
366
358
|
|
367
359
|
def build_records_reducer
|
368
|
-
attributes =
|
360
|
+
attributes = source_column_names
|
369
361
|
key_column_index = attributes.index("_key")
|
370
362
|
|
371
363
|
operators = @sort_keys.collect do |sort_key|
|
@@ -376,12 +368,12 @@ module Droonga
|
|
376
368
|
end
|
377
369
|
{
|
378
370
|
"operator" => operator,
|
379
|
-
"column"
|
371
|
+
"column" => attributes.index(sort_key),
|
380
372
|
}
|
381
373
|
end
|
382
374
|
|
383
375
|
reducer = {
|
384
|
-
"type"
|
376
|
+
"type" => "sort",
|
385
377
|
"operators" => operators,
|
386
378
|
}
|
387
379
|
if unifiable? && !key_column_index.nil?
|
@@ -15,10 +15,10 @@
|
|
15
15
|
# License along with this library; if not, write to the Free Software
|
16
16
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
17
|
|
18
|
-
require "droonga/
|
18
|
+
require "droonga/planner_plugin"
|
19
19
|
|
20
20
|
module Droonga
|
21
|
-
class
|
21
|
+
class GroongaPlanner < Droonga::PlannerPlugin
|
22
22
|
repository.register("groonga", self)
|
23
23
|
|
24
24
|
command :table_create
|
@@ -26,7 +26,7 @@ module Droonga
|
|
26
26
|
unless message["dataset"]
|
27
27
|
raise "dataset must be set. FIXME: This error should return client."
|
28
28
|
end
|
29
|
-
|
29
|
+
broadcast(message)
|
30
30
|
end
|
31
31
|
|
32
32
|
command :table_remove
|
@@ -34,42 +34,21 @@ module Droonga
|
|
34
34
|
unless message["dataset"]
|
35
35
|
raise "dataset must be set. FIXME: This error should return client."
|
36
36
|
end
|
37
|
-
|
37
|
+
broadcast(message)
|
38
38
|
end
|
39
39
|
|
40
40
|
command :column_create
|
41
41
|
def column_create(message)
|
42
|
-
|
42
|
+
broadcast(message)
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
def reducer(message)
|
53
|
-
reducer = super
|
54
|
-
reducer["type"] = "groonga_reduce"
|
55
|
-
reducer["body"]["result"] = {
|
56
|
-
"result_reduced" => {
|
57
|
-
"type" => "groonga_result",
|
58
|
-
},
|
59
|
-
}
|
60
|
-
reducer["inputs"] << "result"
|
61
|
-
reducer["outputs"] << "result_reduced"
|
62
|
-
reducer
|
63
|
-
end
|
64
|
-
|
65
|
-
def gatherer(message)
|
66
|
-
gatherer = super
|
67
|
-
gatherer["type"] = "groonga_gather"
|
68
|
-
gatherer["body"]["result_reduced"] = {
|
69
|
-
"output" => "result",
|
70
|
-
}
|
71
|
-
gatherer["inputs"] << "result_reduced"
|
72
|
-
gatherer
|
46
|
+
def broadcast(message)
|
47
|
+
super(message,
|
48
|
+
:write => true,
|
49
|
+
:reduce => {
|
50
|
+
"result" => "or"
|
51
|
+
})
|
73
52
|
end
|
74
53
|
end
|
75
54
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013 Droonga Project
|
3
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -15,17 +15,17 @@
|
|
15
15
|
# License along with this library; if not, write to the Free Software
|
16
16
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
17
|
|
18
|
-
require "droonga/
|
19
|
-
require "droonga/plugin/
|
18
|
+
require "droonga/planner_plugin"
|
19
|
+
require "droonga/plugin/planner/distributed_search_planner"
|
20
20
|
|
21
21
|
module Droonga
|
22
|
-
class
|
22
|
+
class SearchPlanner < Droonga::PlannerPlugin
|
23
23
|
repository.register("search", self)
|
24
24
|
|
25
25
|
command :search
|
26
26
|
def search(message)
|
27
27
|
planner = DistributedSearchPlanner.new(message)
|
28
|
-
|
28
|
+
planner.plan
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|