Package org.apache.lucene.search
Class TwoPhaseIterator
java.lang.Object
org.apache.lucene.search.TwoPhaseIterator
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
-
Constructor Summary
ModifierConstructorDescriptionprotected
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
.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.
-