[Groonga-commit] droonga/fluent-plugin-droonga at f21cfbc [master] Move the method to sort queries to QuerySorter from Searcher

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Dec 27 10:12:27 JST 2013


YUKI Hiroshi	2013-12-27 10:12:27 +0900 (Fri, 27 Dec 2013)

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

  Message:
    Move the method to sort queries to QuerySorter from Searcher

  Modified files:
    lib/droonga/plugin/distributor/distributed_search_planner.rb
    lib/droonga/searcher.rb

  Modified: lib/droonga/plugin/distributor/distributed_search_planner.rb (+1 -1)
===================================================================
--- lib/droonga/plugin/distributor/distributed_search_planner.rb    2013-12-27 10:09:14 +0900 (af27e18)
+++ lib/droonga/plugin/distributor/distributed_search_planner.rb    2013-12-27 10:12:27 +0900 (d631360)
@@ -36,7 +36,7 @@ module Droonga
     UNLIMITED = -1
 
     def build_messages
-      Searcher.validate_sources(@queries)
+      QuerySorter.validate_sources(@queries)
 
       ensure_unifiable!
 

  Modified: lib/droonga/searcher.rb (+24 -23)
===================================================================
--- lib/droonga/searcher.rb    2013-12-27 10:09:14 +0900 (b997644)
+++ lib/droonga/searcher.rb    2013-12-27 10:12:27 +0900 (be3b340)
@@ -44,28 +44,6 @@ module Droonga
       end
     end
 
-    class << self
-      def sort_queries(queries)
-        query_sorter = QuerySorter.new
-        queries.each do |name, query|
-          source = query["source"]
-          raise MissingSourceParameter.new(name, queries) unless source
-          raise CyclicSource.new(queries) if name == source
-          query_sorter.add(name, [source])
-        end
-        begin
-          sorted_queries = query_sorter.tsort
-        rescue TSort::Cyclic
-          raise CyclicSource.new(queries)
-        end
-        sorted_queries
-      end
-
-      def validate_sources(queries)
-        sort_queries(queries)
-      end
-    end
-
     def initialize(context)
       @context = context
     end
@@ -88,7 +66,7 @@ module Droonga
         return {}
       end
       $log.trace("#{log_tag}: process_queries: sort: start")
-      sorted_queries = self.class.sort_queries(queries)
+      sorted_queries = QuerySorter.sort(queries)
       $log.trace("#{log_tag}: process_queries: sort: done")
       outputs = {}
       results = {}
@@ -124,6 +102,29 @@ module Droonga
 
     class QuerySorter
       include TSort
+
+      class << self
+        def sort(queries)
+          query_sorter = new
+          queries.each do |name, query|
+            source = query["source"]
+            raise MissingSourceParameter.new(name, queries) unless source
+            raise CyclicSource.new(queries) if name == source
+            query_sorter.add(name, [source])
+          end
+          begin
+            sorted_queries = query_sorter.tsort
+          rescue TSort::Cyclic
+            raise CyclicSource.new(queries)
+          end
+          sorted_queries
+        end
+
+        def validate_sources(queries)
+          sort(queries)
+        end
+      end
+
       def initialize()
         @queries = {}
       end
-------------- next part --------------
HTML����������������������������...
下载 



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