[Groonga-commit] droonga/fluent-plugin-droonga at 749bd97 [master] Use Groonga specific collector

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Jan 24 17:30:56 JST 2014


YUKI Hiroshi	2014-01-24 17:30:56 +0900 (Fri, 24 Jan 2014)

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

  Message:
    Use Groonga specific collector

  Copied files:
    lib/droonga/plugin/collector/groonga.rb
      (from lib/droonga/collector.rb)
  Modified files:
    lib/droonga/collector.rb
    lib/droonga/plugin/distributor/groonga.rb

  Modified: lib/droonga/collector.rb (+1 -1)
===================================================================
--- lib/droonga/collector.rb    2014-01-24 17:20:23 +0900 (2c3b682)
+++ lib/droonga/collector.rb    2014-01-24 17:30:56 +0900 (0aaa744)
@@ -23,7 +23,7 @@ module Droonga
     include Pluggable
 
     def initialize
-      load_plugins(["basic", "search"]) # TODO: make customizable
+      load_plugins(["basic", "search", "groonga"]) # TODO: make customizable
     end
 
     private

  Copied: lib/droonga/plugin/collector/groonga.rb (+19 -12) 55%
===================================================================
--- lib/droonga/collector.rb    2014-01-24 17:20:23 +0900 (2c3b682)
+++ lib/droonga/plugin/collector/groonga.rb    2014-01-24 17:30:56 +0900 (1a11bad)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2013 Droonga Project
+# Copyright (C) 2014 Droonga Project
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -15,24 +15,31 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-require "droonga/pluggable"
-require "droonga/collector_plugin"
+require "droonga/plugin/collector/basic"
 
 module Droonga
-  class Collector
-    include Pluggable
+  class GroongaCollector < BasicCollector
+    repository.register("groonga", self)
 
-    def initialize
-      load_plugins(["basic", "search"]) # TODO: make customizable
+    command :collector_groonga_gather
+    def collector_groonga_gather(result)
+      collector_gather(result)
     end
 
-    private
-    def instantiate_plugin(name)
-      CollectorPlugin.repository.instantiate(name)
+    command :collector_groonga_reduce
+    def collector_groonga_reduce(request)
+      collector_reduce(result)
     end
 
-    def log_tag
-      "collector"
+    def reduce(deal, left_value, right_value)
+      reduced_value = nil
+
+      case deal["type"]
+      when "groonga_result"
+        reduced_value = left_value && right_value
+      end
+
+      reduced_value
     end
   end
 end

  Modified: lib/droonga/plugin/distributor/groonga.rb (+3 -1)
===================================================================
--- lib/droonga/plugin/distributor/groonga.rb    2014-01-24 17:20:23 +0900 (b2d09e9)
+++ lib/droonga/plugin/distributor/groonga.rb    2014-01-24 17:30:56 +0900 (7e48402)
@@ -51,9 +51,10 @@ module Droonga
 
     def reducer(message)
       reducer = super
+      reducer["type"] = "groonga_reduce"
       reducer["body"]["result"] = {
         "result_reduced" => {
-          "type" => "sum",
+          "type" => "groonga_result",
         },
       }
       reducer["inputs"] << "result"
@@ -63,6 +64,7 @@ module Droonga
 
     def gatherer(message)
       gatherer = super
+      reducer["type"] = "groonga_gather"
       gatherer["body"]["result_reduced"] = {
         "output" => "result",
       }
-------------- next part --------------
HTML����������������������������...
Download 



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