Navigation Menu

Skip to content

Commit

Permalink
Accept scatter without record
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 14, 2015
1 parent 22c715a commit 562e463
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/droonga/distributed_command_planner.rb
Expand Up @@ -55,12 +55,12 @@ def reduce(params=nil)
end
end

def scatter(record, options={})
def scatter(options={})
@processor = {
"command" => @source_message["type"],
"dataset" => @dataset.name,
"body" => options[:body] || @source_message["body"],
"record" => record,
"record" => options[:record],
"type" => "scatter",
"outputs" => [],
"replica" => options[:replica] || "all",
Expand Down
9 changes: 5 additions & 4 deletions lib/droonga/planner.rb
Expand Up @@ -35,6 +35,7 @@ def plan(message, params={})
options = {
:write => write?,
:random => random?,
:record => params[:record],
}
if @collector_class
reduce_key = "result"
Expand All @@ -43,9 +44,8 @@ def plan(message, params={})
}
end

record = params[:record]
if record
scatter(message, record, options)
if options[:record]
scatter(message, options)
else
broadcast(message, options)
end
Expand All @@ -68,9 +68,10 @@ def scatter(message, record, options={})
planner = DistributedCommandPlanner.new(@dataset, message)
scatter_options = {
:write => options[:write],
:record => options[:record],
}
scatter_options[:replica] = "random" if options[:random]
planner.scatter(record, scatter_options)
planner.scatter(scatter_options)
planner.reduce(options[:reduce])
planner.plan
end
Expand Down

0 comments on commit 562e463

Please sign in to comment.