[Groonga-commit] droonga/fluent-plugin-droonga at fa7fd85 [master] Move search speific operation of reducing from basic collector to search collector

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Jan 24 15:07:49 JST 2014


YUKI Hiroshi	2014-01-24 15:07:49 +0900 (Fri, 24 Jan 2014)

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

  Message:
    Move search speific operation of reducing from basic collector to search collector

  Added files:
    lib/droonga/plugin/collector/search.rb
  Modified files:
    lib/droonga/plugin/collector/basic.rb

  Modified: lib/droonga/plugin/collector/basic.rb (+2 -10)
===================================================================
--- lib/droonga/plugin/collector/basic.rb    2014-01-24 15:05:01 +0900 (dc89d72)
+++ lib/droonga/plugin/collector/basic.rb    2014-01-24 15:07:49 +0900 (8410b69)
@@ -102,22 +102,14 @@ module Droonga
     command :collector_reduce
     def collector_reduce(request)
       return unless request
-      body[input_name].each do |output, elements|
+      body[input_name].each do |output, deal|
         value = request
         old_value = output_values[output]
-        value = reduce_elements(elements, old_value, request) if old_value
+        value = reduce(deal, old_value, request) if old_value
         emit(output, value)
       end
     end
 
-    def reduce_elements(elements, left_values, right_values)
-      result = {}
-      elements.each do |key, deal|
-        result[key] = reduce(deal, left_values[key], right_values[key])
-      end
-      result
-    end
-
     def reduce(deal, left_value, right_value)
         reduced_values = nil
 

  Added: lib/droonga/plugin/collector/search.rb (+43 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/plugin/collector/search.rb    2014-01-24 15:07:49 +0900 (0e22b0b)
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2013-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
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# 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/plugin/collector/basic"
+
+module Droonga
+  class SearchCollector < BasicCollector
+    repository.register("search", self)
+
+    command :collector_reduce
+    def collector_reduce(request)
+      return unless request
+      body[input_name].each do |output, elements|
+        value = request
+        old_value = output_values[output]
+        value = reduce_elements(elements, old_value, request) if old_value
+        emit(output, value)
+      end
+    end
+
+    def reduce_elements(elements, left_values, right_values)
+      result = {}
+      elements.each do |key, deal|
+        result[key] = reduce(deal, left_values[key], right_values[key])
+      end
+      result
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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