Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ 3.6.16

  • Loading branch information...
commit 4c5e13858ba49cd2c053643eb322ce9412d35c00 1 parent 009f973
@floere authored
View
4 history.textile
@@ -1,5 +1,9 @@
h2. Upcoming Version
+h2. Version 3.6.16
+
+* hanke: (server) Semantics for terminate_early(n) are to calculate n more allocations than necessary. A n of 0 means that only exactly the number of necessary allocations for the ids is calculated.
+
h2. Version 3.6.14/15
* hanke: (server) Fix for terminate_early with offsets in 3.6.12 (thanks niko!).
View
11 server/lib/picky/query/allocations.rb
@@ -81,8 +81,8 @@ def process! amount, offset = 0, terminate_early = nil
amount = amount - ids.size # we need less results from the following allocation
offset = 0 # we have already passed the offset
end
- if terminate_early
- break if terminate_early <= 0 && amount <= 0
+ if terminate_early && amount <= 0
+ break if terminate_early <= 0
terminate_early -= 1
end
end
@@ -91,8 +91,11 @@ def process! amount, offset = 0, terminate_early = nil
# The total is simply the sum of the counts of all allocations.
#
def total
- @total ||= inject(0) do |total, allocation|
- total + (allocation.count || break)
+ @total ||= calculate_total
+ end
+ def calculate_total
+ inject(0) do |total, allocation|
+ total + (allocation.count or return total)
end
end
View
44 server/spec/functional/terminate_early_spec.rb
@@ -79,14 +79,14 @@
try.search('hello', 13, 12).ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]
try.search('hello', 13, 16).ids.should == [2, 1, 6, 5, 4, 3, 2, 1]
- try.search('hello', 13).to_hash[:allocations].size.should == 3
- try.search('hello', 13, 4).to_hash[:allocations].size.should == 3
+ try.search('hello', 13).to_hash[:allocations].size.should == 4
+ try.search('hello', 13, 4).to_hash[:allocations].size.should == 4
try.search('hello', 13, 8).to_hash[:allocations].size.should == 4
try.search('hello', 13, 12).to_hash[:allocations].size.should == 4
try.search('hello', 13, 16).to_hash[:allocations].size.should == 4
- try.search('hello', 13).allocations.map(&:count).should == [6, 6, 6, nil]
- try.search('hello', 13, 4).allocations.map(&:count).should == [6, 6, 6, nil]
+ try.search('hello', 13).allocations.map(&:count).should == [6, 6, 6, 6]
+ try.search('hello', 13, 4).allocations.map(&:count).should == [6, 6, 6, 6]
try.search('hello', 13, 8).allocations.map(&:count).should == [6, 6, 6, 6]
try.search('hello', 13, 12).allocations.map(&:count).should == [6, 6, 6, 6]
try.search('hello', 13, 16).allocations.map(&:count).should == [6, 6, 6, 6]
@@ -112,20 +112,42 @@
try.search('hello', 1).to_hash[:allocations].size.should == 2
try.search('hello', 1, 4).to_hash[:allocations].size.should == 2
- try.search('hello', 1, 8).to_hash[:allocations].size.should == 2
- try.search('hello', 1, 12).to_hash[:allocations].size.should == 3
- try.search('hello', 1, 16).to_hash[:allocations].size.should == 3
+ try.search('hello', 1, 8).to_hash[:allocations].size.should == 3
+ try.search('hello', 1, 12).to_hash[:allocations].size.should == 4
+ try.search('hello', 1, 16).to_hash[:allocations].size.should == 4
try.search('hello', 1, 20).to_hash[:allocations].size.should == 4
try.search('hello', 1, 24).to_hash[:allocations].size.should == 4
try.search('hello', 1).allocations.map(&:count).should == [6, 6, nil, nil]
try.search('hello', 1, 4).allocations.map(&:count).should == [6, 6, nil, nil]
- try.search('hello', 1, 8).allocations.map(&:count).should == [6, 6, nil, nil]
- try.search('hello', 1, 12).allocations.map(&:count).should == [6, 6, 6, nil]
- try.search('hello', 1, 16).allocations.map(&:count).should == [6, 6, 6, nil]
+ try.search('hello', 1, 8).allocations.map(&:count).should == [6, 6, 6, nil]
+ try.search('hello', 1, 12).allocations.map(&:count).should == [6, 6, 6, 6]
+ try.search('hello', 1, 16).allocations.map(&:count).should == [6, 6, 6, 6]
try.search('hello', 1, 20).allocations.map(&:count).should == [6, 6, 6, 6]
try.search('hello', 1, 24).allocations.map(&:count).should == [6, 6, 6, 6]
+ try.search('hello', 1, 0).to_hash.should == {
+ :allocations => [
+ [:terminate_early, 1.792, 6, [[:text1, "hello", "hello"]], [6]],
+ [:terminate_early, 1.792, 6, [[:text2, "hello", "hello"]], []]
+ ],
+ :offset => 0,
+ :duration => anything,
+ :total => 12
+ }
+
+ try.search('hello', 1, 12).to_hash.should == {
+ :allocations => [
+ [:terminate_early, 1.792, 6, [[:text1, "hello", "hello"]], []],
+ [:terminate_early, 1.792, 6, [[:text2, "hello", "hello"]], []],
+ [:terminate_early, 1.792, 6, [[:text3, "hello", "hello"]], [6]],
+ [:terminate_early, 1.792, 6, [[:text4, "hello", "hello"]], []]
+ ],
+ :offset => 12,
+ :duration => anything,
+ :total => 24
+ }
+
GC.start
try_slow = Picky::Search.new index
@@ -162,7 +184,7 @@
fast = performance_of do
try_fast.search 'hello hello hello'
end
- (slow/fast).should >= 1.8
+ (slow/fast).should >= 1.7
try_slow = Picky::Search.new index
slow = performance_of do
View
4 server/spec/lib/query/allocations_spec.rb
@@ -121,7 +121,7 @@
it 'should call the process! method right' do
@allocation1.should_receive(:process!).once.with(5,1).and_return [2, 3, 4]
@allocation2.should_receive(:process!).once.with(2,0).and_return [5, 6]
- @allocation3.should_receive(:process!).never
+ @allocation3.should_receive(:process!).once.with(0,0).and_return []
@allocations.process! @amount, @offset, 1
end
@@ -186,7 +186,7 @@
it 'should call the process! method right' do
@allocation1.should_receive(:process!).once.with(5,0).and_return [1, 2, 3, 4]
@allocation2.should_receive(:process!).once.with(1,0).and_return [5]
- @allocation3.should_receive(:process!).never
+ @allocation3.should_receive(:process!).once.with(0,0).and_return []
@allocations.process! @amount, @offset, 1
end
View
2  version.rb
@@ -1,3 +1,3 @@
module Picky
- VERSION = '3.6.15'
+ VERSION = '3.6.16'
end
Please sign in to comment.
Something went wrong with that request. Please try again.