Extension of PostingsEnum which also provides information about upcoming impacts.
| field | type | note |
|---|---|---|
| NO_MORE_DOCS | int | When returned by #nextDoc(), #advance(int) and #docID() it means there
are no more docs in the iterator. |
advance(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. Exhausts the iterator and returns #NO_MORE_DOCS if 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 > current it 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 #NO_MORE_DOCS for 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.
cost()Returns the estimated cost of this DocIdSetIterator.
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.
docID()Returns the following:
-1 if #nextDoc() or #advance(int) were not called yet.
#NO_MORE_DOCS if the iterator has exhausted.
docIDRunEnd()Returns the end of the run of consecutive doc IDs that match this DocIdSetIterator and
that contains the current #docID(), that is: one plus the last doc ID of the run.
#docID().
[docID(), docIDRunEnd()) match this iterator.
#docIDRunEnd().
Note: It is illegal to call this method when the iterator is exhausted or not positioned.
The default implementation assumes runs of a single doc ID and returns #docID()) +
1.
intoBitSet(int upTo, org.apache.lucene.util.FixedBitSet bitSet, int offset)Load doc IDs into a FixedBitSet. 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: offset must be less than or equal to the current doc
ID. Behaviour is undefined if this iterator is unpositioned.
Note: It is important not to clear bits from bitSet that may be already set.
Note: offset may be negative.
nextDoc()Advances to the next document in the set and returns the doc it is currently on, or #NO_MORE_DOCS if 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.
advanceShallow(int target)Shallow-advance to target. This is cheaper than calling DocIdSetIterator#advance(int) and allows further calls to #getImpacts() to ignore doc
IDs that are less than target in order to get more precise information about impacts.
This method may not be called on targets that are less than the current DocIdSetIterator#docID(). After this method has been called, DocIdSetIterator#nextDoc() may not be called if the current doc ID is less than target
- 1 and DocIdSetIterator#advance(int) may not be called on targets that are less than
target.
Get information about upcoming impacts for doc ids that are greater than or equal to the
maximum of DocIdSetIterator#docID() and the last target that was passed to #advanceShallow(int). This method may not be called on an unpositioned iterator on which
#advanceShallow(int) has never been called. NOTE: advancing this iterator may
invalidate the returned impacts, so they should not be used after the iterator has been
advanced.
| field | type | note |
|---|---|---|
| ALL | short | Flag to pass to TermsEnum#postings(PostingsEnum, int) to get positions, payloads and
offsets in the returned enum |
| FREQS | short | Flag to pass to TermsEnum#postings(PostingsEnum, int) if you require term frequencies
in the returned enum. |
| NONE | short | Flag to pass to TermsEnum#postings(PostingsEnum, int) if you don't require per-document
postings in the returned enum. |
| OFFSETS | short | Flag to pass to TermsEnum#postings(PostingsEnum, int) if you require offsets in the
returned enum. |
| PAYLOADS | short | Flag to pass to TermsEnum#postings(PostingsEnum, int) if you require payloads in the
returned enum. |
| POSITIONS | short | Flag to pass to TermsEnum#postings(PostingsEnum, int) if you require term positions in
the returned enum. |
endOffset()Returns end offset for the current position, or -1 if offsets were not indexed.
freq()Returns term frequency in the current document, or 1 if the field was indexed with IndexOptions#DOCS. Do not call this before #nextDoc is first called, nor after #nextDoc returns DocIdSetIterator#NO_MORE_DOCS.
NOTE: if the PostingsEnum was obtain with #NONE, the result of this
method is undefined.
nextPosition()Returns the next position, or -1 if positions were not indexed. Calling this more than #freq() times is undefined.
nextPostings(int upTo, org.apache.lucene.search.DocAndFloatFeatureBuffer buffer)Fill a buffer of doc IDs and frequencies with some number of doc IDs and their corresponding
frequencies, starting at the current doc ID, and ending before upTo. Because it starts
on the current doc ID, it is illegal to call this method if the current doc ID
is -1.
An empty buffer after this method returns indicates that there are no postings left between
the current doc ID and upTo.
Implementations should ideally fill the buffer with a number of entries comprised between 8 and a couple hundreds, to keep heap requirements contained, while still being large enough to enable operations on the buffer to auto-vectorize efficiently.
The default implementation is provided below:
int batchSize = 16; // arbitrary
buffer.growNoCopy(batchSize);
int size = 0;
for (int doc = docID(); doc < upTo && size < batchSize; doc = nextDoc()) {
buffer.docs[size] = doc;
buffer.freqs[size] = freq();
++size;
}
buffer.size = size;
NOTE: The provided DocAndFloatFeatureBuffer should not hold references to
internal data structures.
Returns the payload at this position, or null if no payload was indexed. You should not modify anything (neither members of the returned BytesRef nor bytes in the byte[]).
startOffset()Returns start offset for the current position, or -1 if offsets were not indexed.