Class: Droonga::Dispatcher::SessionPlanner
- Inherits:
-
Object
- Object
- Droonga::Dispatcher::SessionPlanner
- Defined in:
- lib/droonga/dispatcher.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #create_session(id, collector_runner) ⇒ Object
-
#initialize(dispatcher, steps) ⇒ SessionPlanner
constructor
A new instance of SessionPlanner.
- #resolve_descendants ⇒ Object
Constructor Details
#initialize(dispatcher, steps) ⇒ SessionPlanner
302 303 304 305 |
# File 'lib/droonga/dispatcher.rb', line 302 def initialize(dispatcher, steps) @dispatcher = dispatcher @steps = steps end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
300 301 302 |
# File 'lib/droonga/dispatcher.rb', line 300 def steps @steps end |
Instance Method Details
#create_session(id, collector_runner) ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/droonga/dispatcher.rb', line 307 def create_session(id, collector_runner) resolve_descendants tasks = [] inputs = {} @steps.each do |step| step["routes"].each do |route| next unless @dispatcher.local?(route) task = { "route" => route, "step" => step, "n_of_inputs" => 0, "values" => {} } tasks << task (step["inputs"] || [nil]).each do |input| inputs[input] ||= [] inputs[input] << task end end end Session.new(id, @dispatcher, collector_runner, tasks, inputs) end |
#resolve_descendants ⇒ Object
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/droonga/dispatcher.rb', line 330 def resolve_descendants @descendants = {} @steps.size.times do |index| step = @steps[index] (step["inputs"] || []).each do |input| @descendants[input] ||= [] @descendants[input] << index end step["n_of_expects"] = 0 end @steps.each do |step| descendants = {} (step["outputs"] || []).each do |output| descendants[output] = [] @descendants[output].each do |index| @steps[index]["n_of_expects"] += step["routes"].size descendants[output].concat(@steps[index]["routes"]) end end step["descendants"] = descendants end end |