Yoji Shidara
null+****@clear*****
Thu Dec 5 17:15:49 JST 2013
Yoji Shidara 2013-12-05 17:15:49 +0900 (Thu, 05 Dec 2013) New Revision: 24e0f62f787b4e12bae9ebfc6bc60d85d6d289a7 https://github.com/droonga/fluent-plugin-droonga/commit/24e0f62f787b4e12bae9ebfc6bc60d85d6d289a7 Message: Extract calculate_sort_offset! method Modified files: lib/droonga/plugin/distributor/distributed_search_plan.rb Modified: lib/droonga/plugin/distributor/distributed_search_plan.rb (+12 -8) =================================================================== --- lib/droonga/plugin/distributor/distributed_search_plan.rb 2013-12-05 16:59:19 +0900 (f0d21b5) +++ lib/droonga/plugin/distributor/distributed_search_plan.rb 2013-12-05 17:15:49 +0900 (4f430eb) @@ -139,18 +139,12 @@ module Droonga end def calculate_offset_and_limit! - # Offset for workers must be zero, because we have to apply "limit" and - # "offset" on the last gathering phase instead of each reducing phase. - sort_offset = 0 - if rich_sort? - sort_offset = @query["sortBy"]["offset"] || 0 - @query["sortBy"]["offset"] = 0 - end + calculate_sort_offset! output_offset = @output["offset"] || 0 @output["offset"] = 0 if has_records? - final_offset = sort_offset + output_offset + final_offset = @sort_offset + output_offset # We have to calculate limit based on offset. # <A, B = limited integer (0...MAXINT)> @@ -186,6 +180,16 @@ module Droonga @records_limit = final_limit end + def calculate_sort_offset! + # Offset for workers must be zero, because we have to apply "limit" and + # "offset" on the last gathering phase instead of each reducing phase. + @sort_offset = 0 + if rich_sort? + @sort_offset = @query["sortBy"]["offset"] || 0 + @query["sortBy"]["offset"] = 0 + end + end + def has_records? @output["elements"].include?("records") end -------------- next part -------------- HTML����������������������������...Download