Navigation Menu

Skip to content

Commit

Permalink
collector: remove needless "collector_" prefix from collector commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Feb 12, 2014
1 parent e3b1164 commit 5158e40
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
8 changes: 4 additions & 4 deletions lib/droonga/plugin/collector/basic.rb
Expand Up @@ -23,17 +23,17 @@ class BasicCollector < Droonga::CollectorPlugin

UNLIMITED = -1

command :collector_gather
def collector_gather(result)
command :gather
def gather(result)
output = body ? body[input_name] : input_name
if output.is_a?(Hash)
output = output["output"]
end
emit(output, result)
end

command :collector_reduce
def collector_reduce(request)
command :reduce
def reduce(request)
body[input_name].each do |output, deal|
left_value = output_values[output]
right_value = request
Expand Down
8 changes: 4 additions & 4 deletions lib/droonga/plugin/collector/search.rb
Expand Up @@ -21,8 +21,8 @@ module Droonga
class SearchCollector < BasicCollector
repository.register("search", self)

command :collector_search_gather
def collector_search_gather(result)
command :search_gather
def search_gather(result)
output = body ? body[input_name] : input_name
if output.is_a?(Hash)
elements = output["elements"]
Expand Down Expand Up @@ -71,8 +71,8 @@ def apply_output_attributes_and_format(items, output)
items
end

command :collector_search_reduce
def collector_search_reduce(request)
command :search_reduce
def search_reduce(request)
#XXX This is just a workaround. Errors should be handled by the framework itself.
if input_name == "errors"
return collector_reduce(request)
Expand Down
3 changes: 1 addition & 2 deletions lib/droonga/session.rb
Expand Up @@ -49,8 +49,7 @@ def receive(name, value)
tasks.each do |task|
task["n_of_inputs"] += 1
step = task["step"]
type = step["type"]
command = "collector_" + type
command = step["type"]
n_of_expects = step["n_of_expects"]
message = {
"task"=>task,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/plugin/collector/test_basic.rb
Expand Up @@ -69,7 +69,7 @@ def test_gather(data)
"name" => data[:mapping],
"descendants" => nil,
}
@plugin.process("collector_gather", request)
@plugin.process("gather", request)
assert_equal(data[:expected], @outputs.last)
end

Expand Down Expand Up @@ -98,7 +98,7 @@ def test_reduce
"name" => input_name,
"descendants" => nil,
}
@plugin.process("collector_reduce", request)
@plugin.process("reduce", request)
assert_equal([
output_name,
[0, 1, 2, 3, 4, 5],
Expand Down
12 changes: 6 additions & 6 deletions test/unit/plugin/collector/test_search.rb
Expand Up @@ -318,7 +318,7 @@ def test_gather(data)
"name" => data[:mapping],
"descendants" => nil,
}
@plugin.process("collector_search_gather", request)
@plugin.process("search_gather", request)
output_name = data[:mapping]
output_name = output_name["output"] if output_name.is_a?(Hash)
assert_equal([output_name, data[:expected]], @outputs.last)
Expand Down Expand Up @@ -385,7 +385,7 @@ def test_sum
"name" => input_name,
"descendants" => nil,
}
@plugin.process("collector_search_reduce", request)
@plugin.process("search_reduce", request)
assert_equal([
output_name,
{
Expand Down Expand Up @@ -470,7 +470,7 @@ def test_sum_with_limit
"name" => input_name,
"descendants" => nil,
}
@plugin.process("collector_search_reduce", request)
@plugin.process("search_reduce", request)
assert_equal([
output_name,
{
Expand Down Expand Up @@ -551,7 +551,7 @@ def test_sort
"name" => input_name,
"descendants" => nil,
}
@plugin.process("collector_search_reduce", request)
@plugin.process("search_reduce", request)
assert_equal([
output_name,
{
Expand Down Expand Up @@ -635,7 +635,7 @@ def test_sort_with_limit
"name" => input_name,
"descendants" => nil,
}
@plugin.process("collector_search_reduce", request)
@plugin.process("search_reduce", request)
assert_equal([
output_name,
{
Expand Down Expand Up @@ -749,7 +749,7 @@ def test_grouped
"name" => input_name,
"descendants" => nil,
}
@plugin.process("collector_search_reduce", request)
@plugin.process("search_reduce", request)
assert_equal([
output_name,
{
Expand Down

0 comments on commit 5158e40

Please sign in to comment.