Package org.apache.lucene.search
Class TwoPhaseIterator
- java.lang.Object
-
- org.apache.lucene.search.TwoPhaseIterator
-
public abstract class TwoPhaseIterator extends Object
Returned byScorer.twoPhaseIterator()to expose an approximation of aDocIdSetIterator. When theapproximation()'sDocIdSetIterator.nextDoc()orDocIdSetIterator.advance(int)return,matches()needs to be checked in order to know whether the returned doc ID actually matches.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description protected DocIdSetIteratorapproximation
-
Constructor Summary
Constructors Modifier Constructor Description protectedTwoPhaseIterator(DocIdSetIterator approximation)Takes the approximation to be returned byapproximation.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DocIdSetIteratorapproximation()Return an approximation.static DocIdSetIteratorasDocIdSetIterator(TwoPhaseIterator twoPhaseIterator)Return aDocIdSetIteratorview of the providedTwoPhaseIterator.abstract floatmatchCost()An estimate of the expected cost to determine that a single documentmatches().abstract booleanmatches()Return whether the current doc ID thatapproximation()is on matches.static TwoPhaseIteratorunwrap(DocIdSetIterator iterator)If the givenDocIdSetIteratorhas been created withasDocIdSetIterator(org.apache.lucene.search.TwoPhaseIterator), then this will return the wrappedTwoPhaseIterator.
-
-
-
Field Detail
-
approximation
protected final DocIdSetIterator approximation
-
-
Constructor Detail
-
TwoPhaseIterator
protected TwoPhaseIterator(DocIdSetIterator approximation)
Takes the approximation to be returned byapproximation. Not null.
-
-
Method Detail
-
asDocIdSetIterator
public static DocIdSetIterator asDocIdSetIterator(TwoPhaseIterator twoPhaseIterator)
Return aDocIdSetIteratorview of the providedTwoPhaseIterator.
-
unwrap
public static TwoPhaseIterator unwrap(DocIdSetIterator iterator)
If the givenDocIdSetIteratorhas been created withasDocIdSetIterator(org.apache.lucene.search.TwoPhaseIterator), then this will return the wrappedTwoPhaseIterator. Otherwise this returnsnull.
-
approximation
public DocIdSetIterator approximation()
Return an approximation. The returnedDocIdSetIteratoris a superset of the matching documents, and each match needs to be confirmed withmatches()in order to know whether it matches or not.
-
matches
public abstract boolean matches() throws IOExceptionReturn whether the current doc ID thatapproximation()is on matches. This method should only be called when the iterator is positioned -- ie. not whenDocIdSetIterator.docID()is-1orDocIdSetIterator.NO_MORE_DOCS-- and at most once.- Throws:
IOException
-
matchCost
public abstract float matchCost()
An estimate of the expected cost to determine that a single documentmatches(). This can be called before iterating the documents ofapproximation(). Returns an expected cost in number of simple operations like addition, multiplication, comparing two numbers and indexing an array. The returned value must be positive.
-
-