Class: Droonga::Distributor
- Inherits:
-
Object
- Object
- Droonga::Distributor
- Includes:
- TSort
- Defined in:
- lib/droonga/distributor.rb
Defined Under Namespace
Classes: CyclicStepsError, UndefinedInputError
Instance Method Summary collapse
- #distribute(plan) ⇒ Object
-
#initialize(dispatcher) ⇒ Distributor
constructor
A new instance of Distributor.
Constructor Details
#initialize(dispatcher) ⇒ Distributor
Returns a new instance of Distributor.
40 41 42 |
# File 'lib/droonga/distributor.rb', line 40 def initialize(dispatcher) @dispatcher = dispatcher end |
Instance Method Details
#distribute(plan) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/droonga/distributor.rb', line 44 def distribute(plan) @dependency = {} plan.each do |step| @dependency[step] = step["inputs"] next unless step["outputs"] step["outputs"].each do |output| @dependency[output] = [step] end end steps = [] each_strongly_connected_component do |cs| raise CyclicStepsError.new(cs) if cs.size > 1 steps.concat(cs) unless cs.first.is_a? String end @dispatcher.dispatch_steps(steps) end |