Class: Droonga::DistributedCommandPlanner
- Inherits:
-
Object
- Object
- Droonga::DistributedCommandPlanner
- Defined in:
- lib/droonga/distributed_command_planner.rb
Direct Known Subclasses
Constant Summary collapse
- REDUCE_SUM =
"sum"- DEFAULT_LIMIT =
-1
Instance Attribute Summary collapse
-
#dataset ⇒ Object
Returns the value of attribute dataset.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
- #broadcast(options = {}) ⇒ Object
-
#initialize(source_message) ⇒ DistributedCommandPlanner
constructor
A new instance of DistributedCommandPlanner.
- #plan ⇒ Object
- #reduce(params = nil) ⇒ Object
- #scatter(options = {}) ⇒ Object
Constructor Details
#initialize(source_message) ⇒ DistributedCommandPlanner
Returns a new instance of DistributedCommandPlanner.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/droonga/distributed_command_planner.rb', line 26 def initialize() = @key = nil @dataset = nil @outputs = [] @reducers = [] @gatherers = [] @processor = nil plan_errors_handling end |
Instance Attribute Details
#dataset ⇒ Object
Returns the value of attribute dataset.
20 21 22 |
# File 'lib/droonga/distributed_command_planner.rb', line 20 def dataset @dataset end |
#key ⇒ Object
Returns the value of attribute key.
20 21 22 |
# File 'lib/droonga/distributed_command_planner.rb', line 20 def key @key end |
Instance Method Details
#broadcast(options = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/droonga/distributed_command_planner.rb', line 71 def broadcast(={}) processor = { "command" => ["type"], "dataset" => @dataset || ["dataset"], "body" => [:body] || ["body"], "type" => "broadcast", "outputs" => [], "replica" => "random" } if [:write] processor["replica"] = "all" processor["post"] = true end @processor = processor end |
#plan ⇒ Object
40 41 42 |
# File 'lib/droonga/distributed_command_planner.rb', line 40 def plan unified_reducers + unified_gatherers + [fixed_processor] end |
#reduce(params = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/droonga/distributed_command_planner.rb', line 44 def reduce(params=nil) return unless params params.each do |name, reducer| gatherer = nil if reducer.is_a?(Hash) && reducer[:gather] gatherer = reducer[:gather] reducer = reducer[:reduce] end @reducers << (reduce_command, name, reducer) @gatherers << (gather_command, name, gatherer) @outputs << name end end |
#scatter(options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/droonga/distributed_command_planner.rb', line 58 def scatter(={}) @processor = { "command" => ["type"], "dataset" => @dataset || ["dataset"], "body" => [:body] || ["body"], "key" => nil, "type" => "scatter", "outputs" => [], "replica" => "all", "post" => true } end |