Class: Droonga::SingleStep
- Inherits:
-
Object
- Object
- Droonga::SingleStep
- Defined in:
- lib/droonga/single_step.rb
Instance Method Summary collapse
- #find_fact_input(inputs, fact, body) ⇒ Object
-
#initialize(dataset, definition) ⇒ SingleStep
constructor
A new instance of SingleStep.
- #plan(message) ⇒ Object
Constructor Details
#initialize(dataset, definition) ⇒ SingleStep
Returns a new instance of SingleStep.
21 22 23 24 |
# File 'lib/droonga/single_step.rb', line 21 def initialize(dataset, definition) @dataset = dataset @definition = definition end |
Instance Method Details
#find_fact_input(inputs, fact, body) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/droonga/single_step.rb', line 55 def find_fact_input(inputs, fact, body) inputs.each do |key, input| if input[:type] == :table # for backward compatibility. We can remove the following code # when all our catalog.json specify "fact" parameter. return input if fact.nil? return input if body[key] == fact end end nil end |
#plan(message) ⇒ Object
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 52 53 |
# File 'lib/droonga/single_step.rb', line 26 def plan() if ["type"] == "search" # XXX: workaround planner = Plugins::Search::Planner.new(@dataset) return planner.plan() end # XXX: Re-implement me. planner = Planner.new(@dataset) = {} [:write] = @definition.write? collector_class = @definition.collector_class if collector_class reduce_key = "result" [:reduce] = { reduce_key => collector_class.operator, } end body = ["body"] fact_input = find_fact_input(@definition.inputs, @dataset.fact, body) if fact_input record = body[fact_input[:filter]] planner.send(:scatter, , record, ) else planner.send(:broadcast, , ) end end |