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, dispatcher, collector_runner) ⇒ Object
-
#initialize(engine_state, steps) ⇒ SessionPlanner
constructor
A new instance of SessionPlanner.
- #resolve_descendants ⇒ Object
Constructor Details
#initialize(engine_state, steps) ⇒ SessionPlanner
Returns a new instance of SessionPlanner.
305 306 307 308 |
# File 'lib/droonga/dispatcher.rb', line 305 def initialize(engine_state, steps) @engine_state = engine_state @steps = steps end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
303 304 305 |
# File 'lib/droonga/dispatcher.rb', line 303 def steps @steps end |
Instance Method Details
#create_session(id, dispatcher, collector_runner) ⇒ Object
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/droonga/dispatcher.rb', line 310 def create_session(id, dispatcher, collector_runner) resolve_descendants tasks = [] inputs = {} @steps.each do |step| step["routes"].each do |route| next unless @engine_state.local_route?(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
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/droonga/dispatcher.rb', line 333 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| live_routes = @engine_state.remove_dead_routes(step["routes"]) @steps[index]["n_of_expects"] += live_routes.size descendants[output].concat(@steps[index]["routes"]) end end step["descendants"] = descendants end end |