Class BitSetIterator
DocIdSetIterator which iterates over set bits in a bit set.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Field Summary
Fields inherited from class org.apache.lucene.search.DocIdSetIterator
NO_MORE_DOCS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintadvance(int target) Advances to the first beyond the current whose document number is greater than or equal to target, and returns the document number itself.longcost()Returns the estimated cost of thisDocIdSetIterator.intdocID()Returns the following:-1ifDocIdSetIterator.nextDoc()orDocIdSetIterator.advance(int)were not called yet.Return the wrappedBitSet.static FixedBitSetgetFixedBitSetOrNull(DocIdSetIterator iterator) If the provided iterator wraps aFixedBitSet, returns it, otherwise returns null.static SparseFixedBitSetgetSparseFixedBitSetOrNull(DocIdSetIterator iterator) If the provided iterator wraps aSparseFixedBitSet, returns it, otherwise returns null.voidintoBitSet(int upTo, FixedBitSet bitSet, int offset) Load doc IDs into aFixedBitSet.intnextDoc()Advances to the next document in the set and returns the doc it is currently on, orDocIdSetIterator.NO_MORE_DOCSif there are no more docs in the set.
NOTE: after the iterator has exhausted you should not call this method, as it may result in unpredicted behavior.voidsetDocId(int docId) Set the current doc id that this iterator is on.Methods inherited from class org.apache.lucene.search.DocIdSetIterator
all, docIDRunEnd, empty, range, slowAdvance
-
Constructor Details
-
BitSetIterator
Sole constructor.
-
-
Method Details
-
getFixedBitSetOrNull
If the provided iterator wraps aFixedBitSet, returns it, otherwise returns null. -
getSparseFixedBitSetOrNull
If the provided iterator wraps aSparseFixedBitSet, returns it, otherwise returns null. -
getBitSet
Return the wrappedBitSet. -
docID
public int docID()Description copied from class:DocIdSetIteratorReturns the following:-1ifDocIdSetIterator.nextDoc()orDocIdSetIterator.advance(int)were not called yet.DocIdSetIterator.NO_MORE_DOCSif the iterator has exhausted.- Otherwise it should return the doc ID it is currently on.
- Specified by:
docIDin classDocIdSetIterator
-
setDocId
public void setDocId(int docId) Set the current doc id that this iterator is on. -
nextDoc
public int nextDoc()Description copied from class:DocIdSetIteratorAdvances to the next document in the set and returns the doc it is currently on, orDocIdSetIterator.NO_MORE_DOCSif there are no more docs in the set.
NOTE: after the iterator has exhausted you should not call this method, as it may result in unpredicted behavior.- Specified by:
nextDocin classDocIdSetIterator
-
advance
public int advance(int target) Description copied from class:DocIdSetIteratorAdvances to the first beyond the current whose document number is greater than or equal to target, and returns the document number itself. Exhausts the iterator and returnsDocIdSetIterator.NO_MORE_DOCSif target is greater than the highest document number in the set.The behavior of this method is undefined when called with
target ≤ current, or after the iterator has exhausted. Both cases may result in unpredicted behavior.When
target > currentit behaves as if written:int advance(int target) { int doc; while ((doc = nextDoc()) < target) { } return doc; }Some implementations are considerably more efficient than that.NOTE: this method may be called with
DocIdSetIterator.NO_MORE_DOCSfor efficiency by some Scorers. If your implementation cannot efficiently determine that it should exhaust, it is recommended that you check for that value in each call to this method.- Specified by:
advancein classDocIdSetIterator
-
cost
public long cost()Description copied from class:DocIdSetIteratorReturns the estimated cost of thisDocIdSetIterator.This is generally an upper bound of the number of documents this iterator might match, but may be a rough heuristic, hardcoded value, or otherwise completely inaccurate.
- Specified by:
costin classDocIdSetIterator
-
intoBitSet
Description copied from class:DocIdSetIteratorLoad doc IDs into aFixedBitSet. This should behave exactly as if implemented as below, which is the default implementation:for (int doc = docID(); doc < upTo; doc = nextDoc()) { bitSet.set(doc - offset); }Note:
offsetmust be less than or equal to thecurrent doc ID. Behaviour is undefined if this iterator is unpositioned.Note: It is important not to clear bits from
bitSetthat may be already set.Note:
offsetmay be negative.- Overrides:
intoBitSetin classDocIdSetIterator- Throws:
IOException
-