Package org.apache.lucene.index
Class NumericDocValues
java.lang.Object
org.apache.lucene.search.DocIdSetIterator
org.apache.lucene.index.NumericDocValues
- Direct Known Subclasses:
FilterNumericDocValues
A per-document numeric value.
-
Field Summary
Fields inherited from class org.apache.lucene.search.DocIdSetIterator
NO_MORE_DOCS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanadvanceExact(int target) Advance the iterator to exactlytargetand return whethertargethas a value.abstract longReturns the numeric value for the current document ID.voidlongValues(int size, int[] docs, long[] values, long defaultValue) Bulk retrieval of numeric doc values.Methods inherited from class org.apache.lucene.search.DocIdSetIterator
advance, all, cost, docID, docIDRunEnd, empty, intoBitSet, nextDoc, range, slowAdvance
-
Constructor Details
-
NumericDocValues
protected NumericDocValues()Sole constructor. (For invocation by subclass constructors, typically implicit.)
-
-
Method Details
-
longValue
Returns the numeric value for the current document ID. It is illegal to call this method afteradvanceExact(int)returnedfalse.- Returns:
- numeric value
- Throws:
IOException
-
longValues
Bulk retrieval of numeric doc values. This API helps reduce the performance impact of virtual function calls.This API behaves as if implemented as below, which is the default implementation:
public void longValues(int size, int[] docs, long[] values, long defaultValue) throws IOException { for (int i = 0; i < size; ++i) { int doc = docs[i]; long value; if (advanceExact(doc)) { value = longValue(); } else { value = defaultValue; } values[i] = value; } }NOTE: The
docsarray is required to be sorted in ascending order with no duplicates.NOTE: This API doesn't allow callers to know which doc IDs have a value or not. If you need to exclude documents that don't have a value for this field, then you could apply a
FieldExistsQueryas aBooleanClause.Occur.FILTERclause. Another option is to fall back to usingadvanceExact(int)andlongValue()on ranges of doc IDs that may not be dense, e.g.if (size > 0 && values.advannceExact(docs[0]) && values.docIDRunEnd() > docs[size - 1]) { // use values#longValues to retrieve values } else { // some docs may not have a value, use #advanceExact and #longValue }- Parameters:
size- the number of values to retrievedocs- the buffer of doc IDs whose values should be looked upvalues- the buffer of values to filldefaultValue- the value to put in the buffer when a document doesn't have a value- Throws:
IOException
-
advanceExact
Advance the iterator to exactlytargetand return whethertargethas a value.targetmust be greater than or equal to the currentdoc IDand must be a valid doc ID, ie. ≥ 0 and <maxDoc. After this method returns,DocIdSetIterator.docID()returnstarget.Note: it is illegal to call
DocIdSetIterator.intoBitSet(int, org.apache.lucene.util.FixedBitSet, int)orDocIdSetIterator.docIDRunEnd()when this method returns false.- Throws:
IOException
-