24
24
import java .util .HashSet ;
25
25
import java .util .LinkedHashMap ;
26
26
import java .util .Map ;
27
- import java .util .Set ;
28
27
29
28
import org .apache .lucene .index .Term ;
30
29
import org .apache .lucene .search .ConjunctionDISI ;
34
33
import org .apache .lucene .search .Weight ;
35
34
import org .apache .lucene .util .FixedBitSet ;
36
35
import org .opengrok .suggest .query .PhraseScorer ;
36
+ import org .opengrok .suggest .query .data .BitIntsHolder ;
37
37
import org .opengrok .suggest .query .data .IntsHolder ;
38
- import org .opengrok .suggest .query .data .HashIntsHolder ;
39
38
40
39
/**
41
40
* Modified Apache Lucene's SloppyPhraseScorer (now {@link org.apache.lucene.search.SloppyPhraseMatcher}) to remember
@@ -103,9 +102,9 @@ final class CustomSloppyPhraseScorer extends Scorer implements PhraseScorer {
103
102
* We may want to fix this in the future (currently not, for performance reasons).
104
103
*/
105
104
private float phraseFreq () throws IOException {
106
- Set < Integer > allPositions = new HashSet <> ();
105
+ BitIntsHolder allPositions = new BitIntsHolder ();
107
106
108
- HashIntsHolder positions = new HashIntsHolder ();
107
+ BitIntsHolder positions = new BitIntsHolder ();
109
108
110
109
if (phrasePositions .length == 1 ) { // special handling for one term
111
110
end = Integer .MIN_VALUE ;
@@ -116,7 +115,7 @@ private float phraseFreq() throws IOException {
116
115
}
117
116
int matchCount = 0 ;
118
117
while (advancePP (pp )) {
119
- allPositions .add (pp .position + pp .offset );
118
+ allPositions .set (pp .position + pp .offset );
120
119
addPositions (positions , allPositions , pp .position + pp .offset ,0 );
121
120
matchCount ++;
122
121
}
@@ -131,7 +130,7 @@ private float phraseFreq() throws IOException {
131
130
}
132
131
133
132
for (PhrasePositions phrasePositions : this .pq ) {
134
- allPositions .add (phrasePositions .position + phrasePositions .offset );
133
+ allPositions .set (phrasePositions .position + phrasePositions .offset );
135
134
}
136
135
137
136
int numMatches = 0 ;
@@ -147,7 +146,7 @@ private float phraseFreq() throws IOException {
147
146
break ; // pps exhausted
148
147
}
149
148
150
- allPositions .add (pp .position + pp .offset );
149
+ allPositions .set (pp .position + pp .offset );
151
150
152
151
if (pp .position > next ) { // done minimizing current match-length
153
152
if (matchLength <= slop ) {
@@ -180,14 +179,14 @@ private float phraseFreq() throws IOException {
180
179
return numMatches ;
181
180
}
182
181
183
- private void addPositions (Set < Integer > positions , Set < Integer > allPositions , int lastEnd , int matchLength ) {
182
+ private void addPositions (BitIntsHolder positions , IntsHolder allPositions , int lastEnd , int matchLength ) {
184
183
int expectedPos = lastEnd + offset ;
185
184
186
185
int range = this .slop - matchLength ;
187
186
for (int i = 0 ; i < (2 * range ) + 1 ; i ++) {
188
187
int pos = expectedPos + i - range ;
189
- if (pos > 0 && !allPositions .contains (pos )) {
190
- positions .add (pos );
188
+ if (pos > 0 && !allPositions .has (pos )) {
189
+ positions .set (pos );
191
190
}
192
191
}
193
192
}
0 commit comments