[Groonga-commit] droonga/fluent-plugin-droonga at 4cdc68b [master] Make collector options flexible

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Nov 27 19:02:20 JST 2013


YUKI Hiroshi	2013-11-27 19:02:20 +0900 (Wed, 27 Nov 2013)

  New Revision: 4cdc68b53646f8191418e6a61f6aa953abf2da4a
  https://github.com/droonga/fluent-plugin-droonga/commit/4cdc68b53646f8191418e6a61f6aa953abf2da4a

  Message:
    Make collector options flexible

  Modified files:
    lib/droonga/plugin/collector/basic.rb
    lib/droonga/plugin/distributor/search.rb
    test/unit/plugin/handler/test_collector.rb

  Modified: lib/droonga/plugin/collector/basic.rb (+2 -3)
===================================================================
--- lib/droonga/plugin/collector/basic.rb    2013-11-27 18:49:06 +0900 (b2446dc)
+++ lib/droonga/plugin/collector/basic.rb    2013-11-27 19:02:20 +0900 (988be4e)
@@ -41,12 +41,11 @@ module Droonga
     def reduce(elements, *values)
       result = {}
       elements.each do |key, deal|
-        func, *args = deal
-        case func
+        case deal["type"]
         when "sum"
           result[key] = values[0][key] + values[1][key]
         when "sort"
-          result[key] = merge(values[0][key], values[1][key], args)
+          result[key] = merge(values[0][key], values[1][key], deal["order"])
         end
       end
       return result

  Modified: lib/droonga/plugin/distributor/search.rb (+7 -2)
===================================================================
--- lib/droonga/plugin/distributor/search.rb    2013-11-27 18:49:06 +0900 (4093eca)
+++ lib/droonga/plugin/distributor/search.rb    2013-11-27 19:02:20 +0900 (666bf3a)
@@ -40,10 +40,15 @@ module Droonga
         output["elements"].each do |element|
           case element
           when "count"
-            elements[element] = ["sum"]
+            elements[element] = {
+              "type" => "sum",
+            }
           when "records"
             # TODO: must take "sortBy" section into account.
-            elements[element] = ["sort", "<"]
+            elements[element] = {
+              "type" => "sort",
+              "order" => ["<"],
+            }
           end
         end
         reducer = {

  Modified: test/unit/plugin/handler/test_collector.rb (+10 -4)
===================================================================
--- test/unit/plugin/handler/test_collector.rb    2013-11-27 18:49:06 +0900 (bed0dda)
+++ test/unit/plugin/handler/test_collector.rb    2013-11-27 19:02:20 +0900 (1139be0)
@@ -77,8 +77,8 @@ class BasicCollectorHandlerTest < Test::Unit::TestCase
             "body" => {
               input_name => {
                 output_name => {
-                  "numeric_key_records" => ["sum"],
-                  "string_key_records" => ["sum"],
+                  "numeric_key_records" => { "type" => "sum" },
+                  "string_key_records" => { "type" => "sum" },
                 },
               },
             },
@@ -149,8 +149,14 @@ class BasicCollectorHandlerTest < Test::Unit::TestCase
             "body" => {
               input_name => {
                 output_name => {
-                  "numeric_key_records" => ["sort", "<"],
-                  "string_key_records" => ["sort", "<"],
+                  "numeric_key_records" => {
+                    "type" => "sort",
+                    "order" => ["<"],
+                  },
+                  "string_key_records" => {
+                    "type" => "sort",
+                    "order" => ["<"],
+                  },
                 },
               },
             },
-------------- next part --------------
HTML����������������������������...
Download 



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