[Groonga-commit] droonga/fluent-plugin-droonga at e9116b5 [master] Don't output duplicated information

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Jan 31 15:21:56 JST 2014


YUKI Hiroshi	2014-01-31 15:21:56 +0900 (Fri, 31 Jan 2014)

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

  Message:
    Don't output duplicated information

  Modified files:
    lib/droonga/plugin/distributor/distributed_search_planner.rb
    test/unit/plugin/distributor/test_search_planner.rb

  Modified: lib/droonga/plugin/distributor/distributed_search_planner.rb (+19 -5)
===================================================================
--- lib/droonga/plugin/distributor/distributed_search_planner.rb    2014-01-31 14:58:29 +0900 (70450ba)
+++ lib/droonga/plugin/distributor/distributed_search_planner.rb    2014-01-31 15:21:56 +0900 (e56e13a)
@@ -71,9 +71,12 @@ module Droonga
 
       transformer = QueryTransformer.new(query)
 
+      elements = transformer.mappers
+      mapper = {}
+      mapper["elements"] = elements unless elements.empty?
       reduce(input_name,
              transformer.reducers,
-             "elements" => transformer.mappers)
+             mapper)
     end
 
     def reduce(name, reducer, gatherer={})
@@ -98,7 +101,9 @@ module Droonga
         # So we have to override the format and restore it on the gathering
         # phase.
         @records_format = @output["format"] || "simple"
-        @output["format"] = "simple"
+        if @output["format"] && @output["format"] != "simple"
+          @output["format"] = "simple"
+        end
 
         @sort_keys = @query["sortBy"] || []
         @sort_keys = @sort_keys["keys"] || [] if @sort_keys.is_a?(Hash)
@@ -131,13 +136,22 @@ module Droonga
         @records_offset = final_offset
         @records_limit = final_limit
 
+        updated_sort_limit = nil
+        updated_output_limit = nil
         if final_limit == UNLIMITED
-          @output["limit"] = UNLIMITED
+          updated_output_limit = UNLIMITED
         else
           if rich_sort?
-            @query["sortBy"]["limit"] = final_offset + [sort_limit, output_limit].max
+            updated_sort_limit = final_offset + [sort_limit, output_limit].max
           end
-          @output["limit"] = final_offset + final_limit
+          updated_output_limit = final_offset + final_limit
+        end
+
+        if updated_sort_limit && updated_sort_limit != @query["sortBy"]["limit"]
+          @query["sortBy"]["limit"] = updated_sort_limit
+        end
+        if updated_output_limit && updated_output_limit != @output["limit"]
+          @output["limit"] = updated_output_limit
         end
       end
 

  Modified: test/unit/plugin/distributor/test_search_planner.rb (+0 -3)
===================================================================
--- test/unit/plugin/distributor/test_search_planner.rb    2014-01-31 14:58:29 +0900 (64f0ca0)
+++ test/unit/plugin/distributor/test_search_planner.rb    2014-01-31 15:21:56 +0900 (212fbfa)
@@ -253,8 +253,6 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
                            "users" => {
                              "output" => {
                                "elements" => ["count"],
-                               "format"   => "simple", # TODO: remove me
-                               "limit"    => 0,        # TODO: remove me
                              },
                              "source" => "User",
                            },
@@ -276,7 +274,6 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
 
         def test_gather_body
           assert_equal({
-                         "elements" => {}, # TODO: remove me
                          "output" => "users",
                        },
                        gather_message["body"]["users_reduced"])
-------------- next part --------------
HTML����������������������������...
Download 



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