[Groonga-commit] droonga/fluent-plugin-droonga at cd287f3 [master] Unify reducers before distribute

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Jan 29 19:33:42 JST 2014


YUKI Hiroshi	2014-01-29 19:33:42 +0900 (Wed, 29 Jan 2014)

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

  Message:
    Unify reducers before distribute

  Modified files:
    lib/droonga/distributed_command_planner.rb

  Modified: lib/droonga/distributed_command_planner.rb (+32 -1)
===================================================================
--- lib/droonga/distributed_command_planner.rb    2014-01-29 18:20:06 +0900 (477ad7e)
+++ lib/droonga/distributed_command_planner.rb    2014-01-29 19:33:42 +0900 (38781ff)
@@ -35,7 +35,38 @@ module Droonga
     end
 
     def messages
-      @reducers + @gatherers + @processors
+      unified_reducers + unified_gatherers + @processors
+    end
+
+    def unified_reducers
+      unified_reducers = {}
+      @reducers.each do |reducer|
+        type = reducer["type"]
+        unified = unified_reducers[type]
+        if unified
+          unified["body"] = unified["body"].merge(reducer["body"])
+          unified["inputs"] = unified["inputs"] + reducer["inputs"]
+          unified["outputs"] = unified["outputs"] + reducer["outputs"]
+        else
+          unified_reducers[type] = Marshal.load(Marshal.dump(reducer))
+        end
+      end
+      unified_reducers.values
+    end
+
+    def unified_gatherers
+      unified_gatherers = {}
+      @gatherers.each do |gatherer|
+        type = gatherer["type"]
+        unified = unified_gatherers[type]
+        if unified
+          unified["body"] = unified["body"].merge(gatherer["body"])
+          unified["inputs"] = unified["inputs"] + gatherer["inputs"]
+        else
+          unified_gatherers[type] = Marshal.load(Marshal.dump(gatherer))
+        end
+      end
+      unified_gatherers.values
     end
 
     def reduce(name, reducer)
-------------- next part --------------
HTML����������������������������...
Download 



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