A per-document byte[] with presorted values. This is fundamentally an iterator over the int ord values per document, with random access APIs to resolve an int ord to BytesRef.
Per-Document values in a SortedDocValues are deduplicated, dereferenced, and sorted into a dictionary of unique values. A pointer to the dictionary value (ordinal) can be retrieved for each document. Ordinals are dense and in increasing sorted order.
intersect(org.apache.lucene.util.automaton.CompiledAutomaton automaton)Returns a TermsEnum over the values, filtered by a CompiledAutomaton The enum
supports TermsEnum#ord().
Retrieves the value for the specified ordinal. The returned BytesRef may be re-used
across calls to #lookupOrd(int) so make sure to copy it if you want to keep it around.
| name | type | description |
|---|---|---|
| ord | int | ordinal to lookup (must be >= 0 and < #getValueCount()) |
If key exists, returns its ordinal, else returns -insertionPoint-1, like
Arrays.binarySearch.
| name | type | description |
|---|---|---|
| key | org.apache.lucene.util.BytesRef | Key to look up |
ordValue()Returns the ordinal for the current docID. It is illegal to call this method after #advanceExact(int) returned false.
Returns: ordinal for the document: this is dense, starts at 0, then increments by 1 for the next value in sorted order.
Returns a TermsEnum over the values. The enum supports TermsEnum#ord() and
TermsEnum#seekExact(long).
getValueCount() · also: get_value_countReturns the number of unique values.
Returns: number of unique values in this SortedDocValues. This is also equivalent to one plus the maximum ordinal.
| 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.
advanceExact(int target)Advance the iterator to exactly target and return whether target has a value.
target must be greater than or equal to the current doc ID and must be
a valid doc ID, ie. ≥ 0 and < maxDoc. After this method returns, #docID()
returns target.
Note: it is illegal to call DocIdSetIterator#intoBitSet or DocIdSetIterator#docIDRunEnd() when this method returns false.