YUKI Hiroshi
null+****@clear*****
Tue Apr 14 15:53:18 JST 2015
YUKI Hiroshi 2015-04-14 15:53:18 +0900 (Tue, 14 Apr 2015) New Revision: 41f3bb8f3d2d399800105decfcfeaaa92a4cd8d0 https://github.com/droonga/droonga-engine/commit/41f3bb8f3d2d399800105decfcfeaaa92a4cd8d0 Message: Move codes to construct plan from single step definition to planner Modified files: lib/droonga/planner.rb lib/droonga/single_step.rb test/unit/plugins/search/test_planner.rb Modified: lib/droonga/planner.rb (+35 -2) =================================================================== --- lib/droonga/planner.rb 2015-04-14 15:24:43 +0900 (48d5fb2) +++ lib/droonga/planner.rb 2015-04-14 15:53:18 +0900 (2c62d8c) @@ -22,15 +22,48 @@ module Droonga include Loggable include ErrorMessages + attr_writer :write, :random, :collector_class + def initialize(dataset) @dataset = dataset + @write = false + @ramdom = nil + @collector_class = nil end - def plan(message) - raise NotImplemented, "#{self.class.name}\##{__method__} must implement." + def plan(message, params={}) + options = { + :write => write?, + :random => random?, + } + if @collector_class + reduce_key = "result" + options[:reduce] = { + reduce_key => @collector_class.operator, + } + end + + record = params[:record] + if record + scatter(message, record, options) + else + broadcast(message, options) + end end private + def write? + @write + end + + def random? + unles****@rando*****? + @random + else + not write? + end + end + def scatter(message, record, options={}) planner = DistributedCommandPlanner.new(@dataset, message) scatter_options = { Modified: lib/droonga/single_step.rb (+5 -12) =================================================================== --- lib/droonga/single_step.rb 2015-04-14 15:24:43 +0900 (ec22891) +++ lib/droonga/single_step.rb 2015-04-14 15:53:18 +0900 (b5e6bce) @@ -32,24 +32,17 @@ module Droonga # XXX: Re-implement me. planner = Planner.new(@dataset) - options = {} - options[:write] =****@defin*****? - options[:random] =****@defin*****? - collector_class =****@defin*****_class - if collector_class - reduce_key = "result" - options[:reduce] = { - reduce_key => collector_class.operator, - } - end + planner.write =****@defin*****? + planner.random =****@defin*****? + planner.collector_class =****@sdefi*****_class body = message["body"] fact_input = find_fact_input(@definition.inputs, @dataset.fact, body) if fact_input record = body[fact_input[:filter]] - planner.scatter(message, record, options) + planner.plan(message, :record => record) else - planner.broadcast(message, options) + planner.plan(message) end end Modified: test/unit/plugins/search/test_planner.rb (+1 -0) =================================================================== --- test/unit/plugins/search/test_planner.rb 2015-04-14 15:24:43 +0900 (7cb3651) +++ test/unit/plugins/search/test_planner.rb 2015-04-14 15:53:18 +0900 (228572b) @@ -174,6 +174,7 @@ class SearchPlannerTest < Test::Unit::TestCase "query2", ], "replica" => "random", + "post" => false, } message << searcher -------------- next part -------------- HTML����������������������������...Descargar