Skip to content

Commit

Permalink
Don't modify offset and limit for distributed search with just single…
Browse files Browse the repository at this point in the history
… slice
  • Loading branch information
piroor committed Jun 2, 2015
1 parent 8ac10a9 commit e7fd6da
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/droonga/plugins/search/distributed_search_planner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def calculate_offset_and_limit!
@records_offset = final_offset
@records_limit = final_limit

return unless @dataset.sliced?

updated_sort_limit = nil
updated_output_limit = nil
if final_limit == UNLIMITED
Expand All @@ -180,6 +182,7 @@ def calculate_offset_and_limit!
end

def calculate_sort_offset!
return unless @dataset.sliced?
# Offset for workers must be zero, because we have to apply "limit" and
# "offset" on the last gathering phase instead of each reducing phase.
if rich_sort?
Expand Down Expand Up @@ -212,17 +215,18 @@ def output_limit
end

def calculate_output_offset!
return unless @dataset.sliced?
@output["offset"] = 0 if have_records? and @output["offset"]
end

def final_offset
return @original_output_offset unless @dataset.sliced?
return 0 unless @dataset.sliced?

@original_sort_offset + @original_output_offset
end

def final_limit
return @original_output_limit unless @dataset.sliced?
return UNLIMITED unless @dataset.sliced?

if @original_sort_limit == UNLIMITED and
@original_output_limit == UNLIMITED
Expand Down

0 comments on commit e7fd6da

Please sign in to comment.