[Groonga-commit] droonga/fluent-plugin-droonga at 6cef124 [master] Add "key_column" and "merge_columns" options for search reducers

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Dec 4 12:15:09 JST 2013


YUKI Hiroshi	2013-12-04 12:15:09 +0900 (Wed, 04 Dec 2013)

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

  Message:
    Add "key_column" and "merge_columns" options for search reducers

  Modified files:
    lib/droonga/plugin/distributor/search.rb

  Modified: lib/droonga/plugin/distributor/search.rb (+12 -0)
===================================================================
--- lib/droonga/plugin/distributor/search.rb    2013-12-04 11:53:31 +0900 (3e7a7a7)
+++ lib/droonga/plugin/distributor/search.rb    2013-12-04 12:15:09 +0900 (c7a8e5c)
@@ -66,6 +66,7 @@ module Droonga
             final_attributes = collect_output_attributes(output["attributes"])
             output["attributes"] = format_attributes_to_array_style(output["attributes"])
             output["attributes"] += collect_sort_attributes(output["attributes"], query["sortBy"])
+            output["attributes"] << "_key" unless output["attributes"].include?("_key")
  
             elements[element] = sort_reducer(output["attributes"], query["sortBy"])
             # On the reducing phase, we apply only "limit". We cannot apply
@@ -246,12 +247,21 @@ module Droonga
 
     ASCENDING_OPERATOR = "<".freeze
     DESCENDING_OPERATOR = ">".freeze
+    MERGE_ATTRIBUTES = ["_nsubrecs", "_subrecs"]
 
     def sort_reducer(attributes, sort_keys)
       attributes ||= []
       sort_keys ||= []
       sort_keys = sort_keys["keys"] || [] if sort_keys.is_a?(Hash)
 
+      key_column_index = attributes.index("_key")
+      merge_columns = []
+      attributes.each_with_index do |attribute, index|
+        source = attribute
+        source = attribute["source"] if attribute.is_a?(Hash)
+        merge_colums << index if MERGE_ATTRIBUTES.include?(source)
+      end
+
       operators = sort_keys.collect do |sort_key|
         operator = ASCENDING_OPERATOR
         if sort_key[0] == "-"
@@ -267,6 +277,8 @@ module Droonga
       {
         "type" => "sort",
         "operators" => operators,
+        "key_column" => key_column_index,
+        "merge_columns" => merge_columns,
       }
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



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