Package org.apache.lucene.search
Class TwoPhaseIterator
java.lang.Object
org.apache.lucene.search.TwoPhaseIterator
- Direct Known Subclasses:
DocValuesRangeIterator
Returned by
Scorer.twoPhaseIterator()
to expose an approximation of a DocIdSetIterator
. When the approximation()
's DocIdSetIterator.nextDoc()
or
DocIdSetIterator.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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TwoPhaseIterator
(DocIdSetIterator approximation) Takes the approximation to be returned byapproximation
. -
Method Summary
Modifier and TypeMethodDescriptionReturn an approximation.static DocIdSetIterator
asDocIdSetIterator
(TwoPhaseIterator twoPhaseIterator) Return aDocIdSetIterator
view of the providedTwoPhaseIterator
.int
Returns the end of the run of consecutive doc IDs that match thisTwoPhaseIterator
and that contains the current doc ID of the approximation, that is: one plus the last doc ID of the run.abstract float
An estimate of the expected cost to determine that a single documentmatches()
.abstract boolean
matches()
Return whether the current doc ID thatapproximation()
is on matches.static TwoPhaseIterator
unwrap
(DocIdSetIterator iterator) If the givenDocIdSetIterator
has been created withasDocIdSetIterator(org.apache.lucene.search.TwoPhaseIterator)
, then this will return the wrappedTwoPhaseIterator
.
-
Field Details
-
approximation
-
-
Constructor Details
-
TwoPhaseIterator
Takes the approximation to be returned byapproximation
. Not null.
-
-
Method Details
-
asDocIdSetIterator
Return aDocIdSetIterator
view of the providedTwoPhaseIterator
. -
unwrap
If the givenDocIdSetIterator
has been created withasDocIdSetIterator(org.apache.lucene.search.TwoPhaseIterator)
, then this will return the wrappedTwoPhaseIterator
. Otherwise this returnsnull
. -
approximation
Return an approximation. The returnedDocIdSetIterator
is a superset of the matching documents, and each match needs to be confirmed withmatches()
in order to know whether it matches or not. -
matches
Return 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-1
orDocIdSetIterator.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. -
docIDRunEnd
Returns the end of the run of consecutive doc IDs that match thisTwoPhaseIterator
and that contains the current doc ID of the approximation, that is: one plus the last doc ID of the run.Note: It is illegal to call this method when the approximation is exhausted or not positioned.
The default implementation returns the current doc ID of the approximation.
- Throws:
IOException
-