[Groonga-commit] droonga/fluent-plugin-droonga at 9622b64 [master] Detect cyclic soruces by distributed search planner

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Dec 26 19:40:09 JST 2013


YUKI Hiroshi	2013-12-26 19:40:09 +0900 (Thu, 26 Dec 2013)

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

  Message:
    Detect cyclic soruces by distributed search planner

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

  Modified: lib/droonga/plugin/distributor/distributed_search_planner.rb (+4 -0)
===================================================================
--- lib/droonga/plugin/distributor/distributed_search_planner.rb    2013-12-26 19:13:51 +0900 (b371d83)
+++ lib/droonga/plugin/distributor/distributed_search_planner.rb    2013-12-26 19:40:09 +0900 (bb9904e)
@@ -36,6 +36,10 @@ module Droonga
     UNLIMITED = -1
 
     def build_messages
+      if Searcher.have_circular_source?(@queries)
+        raise Searcher::CircularReferenceSource.new(@queries)
+      end
+
       ensure_unifiable!
 
       @queries.each do |input_name, query|

  Modified: lib/droonga/searcher.rb (+16 -0)
===================================================================
--- lib/droonga/searcher.rb    2013-12-26 19:13:51 +0900 (9a8af30)
+++ lib/droonga/searcher.rb    2013-12-26 19:40:09 +0900 (e68acb8)
@@ -44,6 +44,22 @@ module Droonga
       end
     end
 
+    class << self
+      def have_circular_source?(queries)
+        query_sorter = QuerySorter.new
+        queries.each do |name, query|
+          source = query["source"]
+          query_sorter.add(name, [source])
+        end
+        begin
+          sorted_queries = query_sorter.tsort
+        rescue TSort::Cyclic
+          return true
+        end
+        false
+      end
+    end
+
     def initialize(context)
       @context = context
     end
-------------- next part --------------
HTML����������������������������...
Download 



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