YUKI Hiroshi
null+****@clear*****
Thu Dec 5 14:14:24 JST 2013
YUKI Hiroshi 2013-12-05 14:14:24 +0900 (Thu, 05 Dec 2013) New Revision: dfb5c67f8e8aab653949912b520994c30fa28577 https://github.com/droonga/fluent-plugin-droonga/commit/dfb5c67f8e8aab653949912b520994c30fa28577 Message: Reduce indent Modified files: lib/droonga/plugin/distributor/distributed_search_plan.rb Modified: lib/droonga/plugin/distributor/distributed_search_plan.rb (+47 -47) =================================================================== --- lib/droonga/plugin/distributor/distributed_search_plan.rb 2013-12-05 14:13:21 +0900 (d3d43af) +++ lib/droonga/plugin/distributor/distributed_search_plan.rb 2013-12-05 14:14:24 +0900 (4b3252b) @@ -193,62 +193,62 @@ module Droonga def build_count_mapper_and_reducer! return unless @output["elements"].include?("count") - @reducers["count"] = { - "type" => "sum", + @reducers["count"] = { + "type" => "sum", + } + if @output["unifiable"] + if @query["sortBy"] && @query["sortBy"].is_a?(Hash) + @query["sortBy"]["limit"] = -1 + end + @output["limit"] = -1 + mapper = { + "type" => "count", + "target" => "records", } - if @output["unifiable"] - if @query["sortBy"] && @query["sortBy"].is_a?(Hash) - @query["sortBy"]["limit"] = -1 - end - @output["limit"] = -1 - mapper = { - "type" => "count", - "target" => "records", - } - unless @output["elements"].include?("records") - @records_limit = -1 - @output["elements"] << "records" - @output["attributes"] ||= ["_key"] - @output_records = false - end - @mappers["count"] = mapper + unless @output["elements"].include?("records") + @records_limit = -1 + @output["elements"] << "records" + @output["attributes"] ||= ["_key"] + @output_records = false end + @mappers["count"] = mapper + end end def build_records_mapper_and_reducer! # Skip reducing phase for a result with no record output. return if !@output["elements"].include?("records") || @records_limit.zero? - # Append sort key attributes to the list of output attributes - # temporarily, for the reducing phase. After all extra columns - # are removed on the gathering phase. - 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"]) - unifiable = @output["unifiable"] - if unifiable && !@output["attributes"].include?("_key") - @output["attributes"] << "_key" - end - - reducer = sort_reducer(:attributes => @output["attributes"], - :sort_keys => @query["sortBy"], - :unifiable => unifiable) - # On the reducing phase, we apply only "limit". We cannot apply - # "offset" on this phase because the collecter merges a pair of - # results step by step even if there are three or more results. - # Instead, we apply "offset" on the gethering phase. - reducer["limit"] = @output["limit"] - @reducers["records"] = reducer + # Append sort key attributes to the list of output attributes + # temporarily, for the reducing phase. After all extra columns + # are removed on the gathering phase. + 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"]) + unifiable = @output["unifiable"] + if unifiable && !@output["attributes"].include?("_key") + @output["attributes"] << "_key" + end - mapper = { - "type" => "sort", - "offset" => @records_offset, - "limit" => @records_limit, - "format" => @records_format, - "attributes" => final_attributes, - } - mapper["no_output"] = true unless @output_records - @mappers["records"] = mapper + reducer = sort_reducer(:attributes => @output["attributes"], + :sort_keys => @query["sortBy"], + :unifiable => unifiable) + # On the reducing phase, we apply only "limit". We cannot apply + # "offset" on this phase because the collecter merges a pair of + # results step by step even if there are three or more results. + # Instead, we apply "offset" on the gethering phase. + reducer["limit"] = @output["limit"] + @reducers["records"] = reducer + + mapper = { + "type" => "sort", + "offset" => @records_offset, + "limit" => @records_limit, + "format" => @records_format, + "attributes" => final_attributes, + } + mapper["no_output"] = true unless @output_records + @mappers["records"] = mapper end def format_attributes_to_array_style(attributes) -------------- next part -------------- HTML����������������������������...ダウンロード