LUCENE-6274: SloppyPhrase approximations

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1661377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2015-02-21 15:12:17 +00:00
parent 299c492dd3
commit c1f1d4dfef
1 changed files with 45 additions and 0 deletions

View File

@ -606,4 +606,49 @@ final class SloppyPhraseScorer extends Scorer {
@Override
public String toString() { return "scorer(" + weight + ")"; }
@Override
public TwoPhaseDocIdSetIterator asTwoPhaseIterator() {
return new TwoPhaseDocIdSetIterator() {
@Override
public DocIdSetIterator approximation() {
return new DocIdSetIterator() {
@Override
public int docID() {
return SloppyPhraseScorer.this.docID();
}
@Override
public int nextDoc() throws IOException {
return advance(max.doc + 1);
}
@Override
public int advance(int target) throws IOException {
assert target > docID();
if (!advanceMin(target)) {
return NO_MORE_DOCS;
}
while (min.doc < max.doc) {
if (!advanceMin(max.doc)) {
return NO_MORE_DOCS;
}
}
return max.doc;
}
@Override
public long cost() {
return SloppyPhraseScorer.this.cost();
}
};
}
@Override
public boolean matches() throws IOException {
sloppyFreq = phraseFreq(); // check for phrase
return sloppyFreq != 0F;
}
};
}
}