Skip to content

Commit

Permalink
Apply maximum valeu as the sortBy-limit, if both sortBy-limit and out…
Browse files Browse the repository at this point in the history
…put-limit are given
  • Loading branch information
piroor committed Dec 9, 2013
1 parent 1d19e24 commit 7233da5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/droonga/plugin/distributor/distributed_search_plan.rb
Expand Up @@ -154,7 +154,7 @@ def calculate_offset_and_limit!
# | UNLIMITED | UNLIMITED | => | UNLIMITED | UNLIMITED | UNLIMITED |
# | UNLIMITED | B | => | final_offset + B | final_offset + B | B |
# | A | UNLIMITED | => | final_offset + A | final_offset + A | A |
# | A | B | => | final_offset + min(A, B) | final_offset + min(A, B)| min(A, B) |
# | A | B | => | final_offset + max(A, B) | final_offset + min(A, B)| min(A, B) |

# XXX final_limit and final_offset calculated in many times

Expand All @@ -164,7 +164,9 @@ def calculate_offset_and_limit!
if final_limit == UNLIMITED
@output["limit"] = UNLIMITED
else
@query["sortBy"]["limit"] = final_offset + final_limit if rich_sort?
if rich_sort?
@query["sortBy"]["limit"] = final_offset + [sort_limit, output_limit].max
end
@output["limit"] = final_offset + final_limit
end
end
Expand Down

0 comments on commit 7233da5

Please sign in to comment.