[Groonga-commit] droonga/fluent-plugin-droonga at 6a883f3 [master] Support dimension in catalog.json

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Mar 19 11:48:25 JST 2014


Kouhei Sutou	2014-03-19 11:48:25 +0900 (Wed, 19 Mar 2014)

  New Revision: 6a883f341332ba7c20cfc710359fd354f3b0cece
  https://github.com/droonga/fluent-plugin-droonga/commit/6a883f341332ba7c20cfc710359fd354f3b0cece

  Message:
    Support dimension in catalog.json
    
    TODO: Add a test for no "_key" dimension. It should work with only
    catalog.json version 2. We need to add "omit" directive support to
    drntest.

  Modified files:
    lib/droonga/catalog/version1.rb
    lib/droonga/catalog/version2.rb
    lib/droonga/distributed_command_planner.rb
    lib/droonga/planner.rb
    lib/droonga/plugins/crud.rb
    lib/droonga/single_step.rb

  Modified: lib/droonga/catalog/version1.rb (+1 -1)
===================================================================
--- lib/droonga/catalog/version1.rb    2014-03-19 11:36:03 +0900 (27387c4)
+++ lib/droonga/catalog/version1.rb    2014-03-19 11:48:25 +0900 (a38c7bb)
@@ -75,7 +75,7 @@ module Droonga
             select_range_and_replicas(partition, args, routes)
           end
         when "scatter"
-          name = get_partition(dataset, args["key"])
+          name = get_partition(dataset, args["record"]["_key"])
           partition = dataset["ring"][name]
           select_range_and_replicas(partition, args, routes)
         end

  Modified: lib/droonga/catalog/version2.rb (+3 -1)
===================================================================
--- lib/droonga/catalog/version2.rb    2014-03-19 11:36:03 +0900 (02cfcc3)
+++ lib/droonga/catalog/version2.rb    2014-03-19 11:48:25 +0900 (130b051)
@@ -70,7 +70,9 @@ module Droonga
         when "scatter"
           replicas = select_replicas(dataset["replicas"], args["replica"])
           replicas.each do |replica|
-            slice = select_slice(replica, args["key"])
+            dimension = replica["dimension"] || "_key"
+            key = args["key"] || args["record"][dimension]
+            slice = select_slice(replica, key)
             routes << slice["volume"]["address"]
           end
         end

  Modified: lib/droonga/distributed_command_planner.rb (+2 -6)
===================================================================
--- lib/droonga/distributed_command_planner.rb    2014-03-19 11:36:03 +0900 (eed18e3)
+++ lib/droonga/distributed_command_planner.rb    2014-03-19 11:48:25 +0900 (c786b8d)
@@ -55,12 +55,12 @@ module Droonga
       end
     end
 
-    def scatter(options={})
+    def scatter(record, options={})
       @processor = {
         "command" => @source_message["type"],
         "dataset" => @dataset || @source_message["dataset"],
         "body"    => options[:body] || @source_message["body"],
-        "key"     => nil,
+        "record"  => record,
         "type"    => "scatter",
         "outputs" => [],
         "replica" => "all",
@@ -126,10 +126,6 @@ module Droonga
 
     def fixed_processor
       @processor["outputs"] = @outputs
-      if @processor["type"] == "scatter"
-        raise ErrorMessages::InternalServerError.new("missing key") unless @key
-        @processor["key"] = @key
-      end
       @processor
     end
 

  Modified: lib/droonga/planner.rb (+2 -3)
===================================================================
--- lib/droonga/planner.rb    2014-03-19 11:36:03 +0900 (34a6898)
+++ lib/droonga/planner.rb    2014-03-19 11:48:25 +0900 (62bf51d)
@@ -30,10 +30,9 @@ module Droonga
     end
 
     private
-    def scatter(message, options={})
+    def scatter(message, record, options={})
       planner = DistributedCommandPlanner.new(message)
-      planner.scatter
-      planner.key = options[:key]
+      planner.scatter(record)
       planner.reduce(options[:reduce])
       planner.plan
     end

  Modified: lib/droonga/plugins/crud.rb (+1 -1)
===================================================================
--- lib/droonga/plugins/crud.rb    2014-03-19 11:36:03 +0900 (e2ca86b)
+++ lib/droonga/plugins/crud.rb    2014-03-19 11:48:25 +0900 (7b7a6e6)
@@ -32,7 +32,7 @@ module Droonga
           request = input_message.body
           key = request["key"] || rand.to_s
           values = request["values"] || {}
-          request["filter"] = values.merge("key" => key)
+          request["filter"] = values.merge("_key" => key)
         end
 
         def adapt_output(output_message)

  Modified: lib/droonga/single_step.rb (+2 -2)
===================================================================
--- lib/droonga/single_step.rb    2014-03-19 11:36:03 +0900 (217b69a)
+++ lib/droonga/single_step.rb    2014-03-19 11:48:25 +0900 (af9e5c9)
@@ -45,8 +45,8 @@ module Droonga
       body = message["body"]
       fact_input = find_fact_input(@definition.inputs, @dataset.fact, body)
       if fact_input
-        options[:key] = body[fact_input[:filter]]["key"]
-        planner.send(:scatter, message, options)
+        record = body[fact_input[:filter]]
+        planner.send(:scatter, message, record, options)
       else
         planner.send(:broadcast, message, options)
       end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index