Class BinaryDocValues
- Direct Known Subclasses:
BinaryRangeDocValues,FilterBinaryDocValues
-
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 BytesRefReturns the binary value for the current document ID.voidbinaryValues(int size, int[] docs, int docsOffset, BytesRef[] values, int valuesOffset) Offset-aware variant ofbinaryValues(int, int[], BytesRef[]).voidbinaryValues(int size, int[] docs, BytesRef[] values) Bulk retrieval of binary doc values.Methods inherited from class org.apache.lucene.search.DocIdSetIterator
advance, all, cost, docID, docIDRunEnd, empty, intoArray, intoBitSet, nextDoc, range, slowAdvance
-
Constructor Details
-
BinaryDocValues
protected BinaryDocValues()Sole constructor. (For invocation by subclass constructors, typically implicit.)
-
-
Method Details
-
binaryValue
Returns the binary value for the current document ID. It is illegal to call this method afteradvanceExact(int)returnedfalse.- Returns:
- binary value
- Throws:
IOException
-
binaryValues
Bulk retrieval of binary 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 binaryValues(int size, int[] docs, BytesRef[] values) throws IOException { for (int i = 0; i < size; ++i) { int doc = docs[i]; if (advanceExact(doc)) { values[i] = BytesRef.deepCopyOf(binaryValue()); } else { values[i] = null; } } }NOTE: The
docsarray is required to be sorted in ascending order with no duplicates.NOTE: Documents that don't have a value for this field will have their corresponding entry set to
null. If you need to exclude documents that don't have a value, then you could apply aFieldExistsQueryas aBooleanClause.Occur.FILTERclause. Another option is to fall back to usingadvanceExact(int)andbinaryValue()on ranges of doc IDs that may not be dense, e.g.if (size > 0 && values.advanceExact(docs[0]) && values.docIDRunEnd() > docs[size - 1]) { // use values#binaryValues to retrieve values } else { // some docs may not have a value, use #advanceExact and #binaryValue }NOTE: Each returned
BytesRefis a deep copy owned by the caller and remains valid after subsequent calls.- Parameters:
size- the number of values to retrievedocs- the buffer of doc IDs whose values should be looked upvalues- the buffer of values to fill; entries are set tonullwhen a document doesn't have a value- Throws:
IOException
-
binaryValues
public void binaryValues(int size, int[] docs, int docsOffset, BytesRef[] values, int valuesOffset) throws IOException Offset-aware variant ofbinaryValues(int, int[], BytesRef[]). Readssizedoc IDs starting atdocs[docsOffset]and writes the corresponding values starting atvalues[valuesOffset]. This follows the same convention asSystem.arraycopy(java.lang.Object, int, java.lang.Object, int, int).- Parameters:
size- the number of values to retrievedocs- the buffer of doc IDs whose values should be looked updocsOffset- first position indocsto readvalues- the buffer of values to fill; entries are set tonullwhen a document doesn't have a valuevaluesOffset- first position invaluesto write- 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
-