picky 3.6.15 → 3.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ module Picky
|
|
11
11
|
:first,
|
12
12
|
:inject,
|
13
13
|
:size,
|
14
|
+
:map,
|
14
15
|
:to => :@allocations
|
15
16
|
|
16
17
|
def initialize allocations = []
|
@@ -80,8 +81,8 @@ module Picky
|
|
80
81
|
amount = amount - ids.size # we need less results from the following allocation
|
81
82
|
offset = 0 # we have already passed the offset
|
82
83
|
end
|
83
|
-
if terminate_early
|
84
|
-
break if terminate_early <= 0
|
84
|
+
if terminate_early && amount <= 0
|
85
|
+
break if terminate_early <= 0
|
85
86
|
terminate_early -= 1
|
86
87
|
end
|
87
88
|
end
|
@@ -90,8 +91,11 @@ module Picky
|
|
90
91
|
# The total is simply the sum of the counts of all allocations.
|
91
92
|
#
|
92
93
|
def total
|
93
|
-
@total ||=
|
94
|
-
|
94
|
+
@total ||= calculate_total
|
95
|
+
end
|
96
|
+
def calculate_total
|
97
|
+
inject(0) do |total, allocation|
|
98
|
+
total + (allocation.count or return total)
|
95
99
|
end
|
96
100
|
end
|
97
101
|
|
@@ -79,12 +79,18 @@ describe 'Search#terminate_early' do
|
|
79
79
|
try.search('hello', 13, 12).ids.should == [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]
|
80
80
|
try.search('hello', 13, 16).ids.should == [2, 1, 6, 5, 4, 3, 2, 1]
|
81
81
|
|
82
|
-
try.search('hello', 13).to_hash[:allocations].size.should ==
|
83
|
-
try.search('hello', 13, 4).to_hash[:allocations].size.should ==
|
82
|
+
try.search('hello', 13).to_hash[:allocations].size.should == 4
|
83
|
+
try.search('hello', 13, 4).to_hash[:allocations].size.should == 4
|
84
84
|
try.search('hello', 13, 8).to_hash[:allocations].size.should == 4
|
85
85
|
try.search('hello', 13, 12).to_hash[:allocations].size.should == 4
|
86
86
|
try.search('hello', 13, 16).to_hash[:allocations].size.should == 4
|
87
87
|
|
88
|
+
try.search('hello', 13).allocations.map(&:count).should == [6, 6, 6, 6]
|
89
|
+
try.search('hello', 13, 4).allocations.map(&:count).should == [6, 6, 6, 6]
|
90
|
+
try.search('hello', 13, 8).allocations.map(&:count).should == [6, 6, 6, 6]
|
91
|
+
try.search('hello', 13, 12).allocations.map(&:count).should == [6, 6, 6, 6]
|
92
|
+
try.search('hello', 13, 16).allocations.map(&:count).should == [6, 6, 6, 6]
|
93
|
+
|
88
94
|
try = Picky::Search.new index do
|
89
95
|
terminate_early with_extra_allocations: 2
|
90
96
|
end
|
@@ -106,12 +112,42 @@ describe 'Search#terminate_early' do
|
|
106
112
|
|
107
113
|
try.search('hello', 1).to_hash[:allocations].size.should == 2
|
108
114
|
try.search('hello', 1, 4).to_hash[:allocations].size.should == 2
|
109
|
-
try.search('hello', 1, 8).to_hash[:allocations].size.should ==
|
110
|
-
try.search('hello', 1, 12).to_hash[:allocations].size.should ==
|
111
|
-
try.search('hello', 1, 16).to_hash[:allocations].size.should ==
|
115
|
+
try.search('hello', 1, 8).to_hash[:allocations].size.should == 3
|
116
|
+
try.search('hello', 1, 12).to_hash[:allocations].size.should == 4
|
117
|
+
try.search('hello', 1, 16).to_hash[:allocations].size.should == 4
|
112
118
|
try.search('hello', 1, 20).to_hash[:allocations].size.should == 4
|
113
119
|
try.search('hello', 1, 24).to_hash[:allocations].size.should == 4
|
114
120
|
|
121
|
+
try.search('hello', 1).allocations.map(&:count).should == [6, 6, nil, nil]
|
122
|
+
try.search('hello', 1, 4).allocations.map(&:count).should == [6, 6, nil, nil]
|
123
|
+
try.search('hello', 1, 8).allocations.map(&:count).should == [6, 6, 6, nil]
|
124
|
+
try.search('hello', 1, 12).allocations.map(&:count).should == [6, 6, 6, 6]
|
125
|
+
try.search('hello', 1, 16).allocations.map(&:count).should == [6, 6, 6, 6]
|
126
|
+
try.search('hello', 1, 20).allocations.map(&:count).should == [6, 6, 6, 6]
|
127
|
+
try.search('hello', 1, 24).allocations.map(&:count).should == [6, 6, 6, 6]
|
128
|
+
|
129
|
+
try.search('hello', 1, 0).to_hash.should == {
|
130
|
+
:allocations => [
|
131
|
+
[:terminate_early, 1.792, 6, [[:text1, "hello", "hello"]], [6]],
|
132
|
+
[:terminate_early, 1.792, 6, [[:text2, "hello", "hello"]], []]
|
133
|
+
],
|
134
|
+
:offset => 0,
|
135
|
+
:duration => anything,
|
136
|
+
:total => 12
|
137
|
+
}
|
138
|
+
|
139
|
+
try.search('hello', 1, 12).to_hash.should == {
|
140
|
+
:allocations => [
|
141
|
+
[:terminate_early, 1.792, 6, [[:text1, "hello", "hello"]], []],
|
142
|
+
[:terminate_early, 1.792, 6, [[:text2, "hello", "hello"]], []],
|
143
|
+
[:terminate_early, 1.792, 6, [[:text3, "hello", "hello"]], [6]],
|
144
|
+
[:terminate_early, 1.792, 6, [[:text4, "hello", "hello"]], []]
|
145
|
+
],
|
146
|
+
:offset => 12,
|
147
|
+
:duration => anything,
|
148
|
+
:total => 24
|
149
|
+
}
|
150
|
+
|
115
151
|
GC.start
|
116
152
|
|
117
153
|
try_slow = Picky::Search.new index
|
@@ -148,7 +184,7 @@ describe 'Search#terminate_early' do
|
|
148
184
|
fast = performance_of do
|
149
185
|
try_fast.search 'hello hello hello'
|
150
186
|
end
|
151
|
-
(slow/fast).should >= 1.
|
187
|
+
(slow/fast).should >= 1.7
|
152
188
|
|
153
189
|
try_slow = Picky::Search.new index
|
154
190
|
slow = performance_of do
|
@@ -121,7 +121,7 @@ describe Picky::Query::Allocations do
|
|
121
121
|
it 'should call the process! method right' do
|
122
122
|
@allocation1.should_receive(:process!).once.with(5,1).and_return [2, 3, 4]
|
123
123
|
@allocation2.should_receive(:process!).once.with(2,0).and_return [5, 6]
|
124
|
-
@allocation3.should_receive(:process!).
|
124
|
+
@allocation3.should_receive(:process!).once.with(0,0).and_return []
|
125
125
|
|
126
126
|
@allocations.process! @amount, @offset, 1
|
127
127
|
end
|
@@ -186,7 +186,7 @@ describe Picky::Query::Allocations do
|
|
186
186
|
it 'should call the process! method right' do
|
187
187
|
@allocation1.should_receive(:process!).once.with(5,0).and_return [1, 2, 3, 4]
|
188
188
|
@allocation2.should_receive(:process!).once.with(1,0).and_return [5]
|
189
|
-
@allocation3.should_receive(:process!).
|
189
|
+
@allocation3.should_receive(:process!).once.with(0,0).and_return []
|
190
190
|
|
191
191
|
@allocations.process! @amount, @offset, 1
|
192
192
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70259516646360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70259516646360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: picky-client
|
27
|
-
requirement: &
|
27
|
+
requirement: &70259516645760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 3.6.
|
32
|
+
version: 3.6.16
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70259516645760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rack
|
38
|
-
requirement: &
|
38
|
+
requirement: &70259516645320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70259516645320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rack_fast_escape
|
49
|
-
requirement: &
|
49
|
+
requirement: &70259516644860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70259516644860
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: text
|
60
|
-
requirement: &
|
60
|
+
requirement: &70259516644400 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70259516644400
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yajl-ruby
|
71
|
-
requirement: &
|
71
|
+
requirement: &70259516643960 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70259516643960
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: activesupport
|
82
|
-
requirement: &
|
82
|
+
requirement: &70259516659780 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '3.0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70259516659780
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: unicorn
|
93
|
-
requirement: &
|
93
|
+
requirement: &70259516659260 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70259516659260
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: sinatra
|
104
|
-
requirement: &
|
104
|
+
requirement: &70259516658620 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70259516658620
|
113
113
|
description: Fast Ruby semantic text search engine with comfortable single field interface.
|
114
114
|
email: florian.hanke+picky@gmail.com
|
115
115
|
executables:
|