Class: Droonga::SingleStep

Inherits:
Object
  • Object
show all
Defined in:
lib/droonga/single_step.rb

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ SingleStep

Returns a new instance of SingleStep.



21
22
23
# File 'lib/droonga/single_step.rb', line 21

def initialize(definition)
  @definition = definition
end

Instance Method Details

#plan(message) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/droonga/single_step.rb', line 25

def plan(message)
  if message["type"] == "search"
    # XXX: workaround
    planner = Plugins::Search::Planner.new
    return planner.plan(message)
  end

  # XXX: Re-implement me.
  planner = Planner.new
  options = {}
  options[:write] = @definition.write?
  collector_class = @definition.collector_class
  if collector_class
    reduce_key = "result"
    options[:reduce] = {
      reduce_key => collector_class.operator,
    }
  end
  inputs = @definition.inputs
  if inputs.empty?
    planner.send(:broadcast, message, options)
  else
    input = inputs.values.first
    options[:key] = message["body"][input[:filter]]["key"]
    planner.send(:scatter, message, options)
  end
end