Class DocValuesConsumer
- All Implemented Interfaces:
Closeable
,AutoCloseable
The lifecycle is:
- DocValuesConsumer is created by
DocValuesFormat.fieldsConsumer(SegmentWriteState)
. addNumericField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
,addBinaryField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
,addSortedField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
,addSortedSetField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
, oraddSortedNumericField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
are called for each Numeric, Binary, Sorted, SortedSet, or SortedNumeric docvalues field. The API is a "pull" rather than "push", and the implementation is free to iterate over the values multiple times (Iterable.iterator()
).- After all fields are added, the consumer is
Closeable.close()
d.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
addBinaryField
(FieldInfo field, DocValuesProducer valuesProducer) Writes binary docvalues for a field.abstract void
addNumericField
(FieldInfo field, DocValuesProducer valuesProducer) Writes numeric docvalues for a field.abstract void
addSortedField
(FieldInfo field, DocValuesProducer valuesProducer) Writes pre-sorted binary docvalues for a field.abstract void
addSortedNumericField
(FieldInfo field, DocValuesProducer valuesProducer) Writes pre-sorted numeric docvalues for a fieldabstract void
addSortedSetField
(FieldInfo field, DocValuesProducer valuesProducer) Writes pre-sorted set docvalues for a fieldprotected static OrdinalMap
createOrdinalMapForSortedDV
(FieldInfo fieldInfo, MergeState mergeState) Returns a merged sorted doc values instance from all producers in the provided merge state.protected static OrdinalMap
createOrdinalMapForSortedSetDV
(List<SortedSetDocValues> toMerge, MergeState mergeState) Creates an ordinal map based on the provided sorted set doc values to mergesprotected static BinaryDocValues
getMergedBinaryDocValues
(FieldInfo mergeFieldInfo, MergeState mergeState) Returns a merged binary doc values instance from all producers in the provided merge state.protected static NumericDocValues
getMergedNumericDocValues
(MergeState mergeState, FieldInfo mergeFieldInfo) Returns a merged numeric doc values instance from all producers in the provided merge state.protected static SortedNumericDocValues
getMergedSortedNumericDocValues
(FieldInfo mergeFieldInfo, MergeState mergeState) Returns a merged sorted numeric doc values instance from all producers in the provided merge state.protected static SortedDocValues
getMergedSortedSetDocValues
(FieldInfo fieldInfo, MergeState mergeState, OrdinalMap map) Returns a merged sorted doc values instance from all producers in the provided merge state.protected static SortedSetDocValues
getMergedSortedSetDocValues
(FieldInfo mergeFieldInfo, MergeState mergeState, OrdinalMap map, List<SortedSetDocValues> toMerge) Returns a sorted set doc values instance from all producers in the provided merge state.static boolean
isSingleValued
(Iterable<Number> docToValueCount) Helper: returns true if the given docToValue count contains only at most one valuevoid
merge
(MergeState mergeState) Merges in the fields from the readers inmergeState
.void
mergeBinaryField
(FieldInfo mergeFieldInfo, MergeState mergeState) Merges the binary docvalues fromMergeState
.void
mergeNumericField
(FieldInfo mergeFieldInfo, MergeState mergeState) Merges the numeric docvalues fromMergeState
.void
mergeSortedField
(FieldInfo fieldInfo, MergeState mergeState) Merges the sorted docvalues fromtoMerge
.void
mergeSortedNumericField
(FieldInfo mergeFieldInfo, MergeState mergeState) Merges the sorted docvalues fromtoMerge
.void
mergeSortedSetField
(FieldInfo mergeFieldInfo, MergeState mergeState) Merges the sortedset docvalues fromtoMerge
.protected static SortedDocValues
mergeSortedValues
(List<org.apache.lucene.codecs.DocValuesConsumer.SortedDocValuesSub> subs, MergeState mergeState, OrdinalMap map) Returns a merged sorted doc values instance from all producers in the provided merge state.protected static List
<SortedSetDocValues> selectLeavesToMerge
(FieldInfo mergeFieldInfo, MergeState mergeState) Selects the sorted set doc values to merge.Helper: returns single-valued view, usingmissingValue
when count is zero
-
Constructor Details
-
DocValuesConsumer
protected DocValuesConsumer()Sole constructor. (For invocation by subclass constructors, typically implicit.)
-
-
Method Details
-
addNumericField
public abstract void addNumericField(FieldInfo field, DocValuesProducer valuesProducer) throws IOException Writes numeric docvalues for a field.- Parameters:
field
- field informationvaluesProducer
- Numeric values to write.- Throws:
IOException
- if an I/O error occurred.
-
addBinaryField
public abstract void addBinaryField(FieldInfo field, DocValuesProducer valuesProducer) throws IOException Writes binary docvalues for a field.- Parameters:
field
- field informationvaluesProducer
- Binary values to write.- Throws:
IOException
- if an I/O error occurred.
-
addSortedField
public abstract void addSortedField(FieldInfo field, DocValuesProducer valuesProducer) throws IOException Writes pre-sorted binary docvalues for a field.- Parameters:
field
- field informationvaluesProducer
- produces the values and ordinals to write- Throws:
IOException
- if an I/O error occurred.
-
addSortedNumericField
public abstract void addSortedNumericField(FieldInfo field, DocValuesProducer valuesProducer) throws IOException Writes pre-sorted numeric docvalues for a field- Parameters:
field
- field informationvaluesProducer
- produces the values to write- Throws:
IOException
- if an I/O error occurred.
-
addSortedSetField
public abstract void addSortedSetField(FieldInfo field, DocValuesProducer valuesProducer) throws IOException Writes pre-sorted set docvalues for a field- Parameters:
field
- field informationvaluesProducer
- produces the values to write- Throws:
IOException
- if an I/O error occurred.
-
merge
Merges in the fields from the readers inmergeState
. The default implementation callsmergeNumericField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState)
,mergeBinaryField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState)
,mergeSortedField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState)
,mergeSortedSetField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState)
, ormergeSortedNumericField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState)
for each field, depending on its type. Implementations can override this method for more sophisticated merging (bulk-byte copying, etc).- Throws:
IOException
-
mergeNumericField
Merges the numeric docvalues fromMergeState
.The default implementation calls
addNumericField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
, passing a DocValuesProducer that merges and filters deleted documents on the fly.- Throws:
IOException
-
getMergedNumericDocValues
protected static NumericDocValues getMergedNumericDocValues(MergeState mergeState, FieldInfo mergeFieldInfo) throws IOException Returns a merged numeric doc values instance from all producers in the provided merge state.- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
mergeBinaryField
Merges the binary docvalues fromMergeState
.The default implementation calls
addBinaryField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
, passing a DocValuesProducer that merges and filters deleted documents on the fly.- Throws:
IOException
-
getMergedBinaryDocValues
protected static BinaryDocValues getMergedBinaryDocValues(FieldInfo mergeFieldInfo, MergeState mergeState) throws IOException Returns a merged binary doc values instance from all producers in the provided merge state.- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
mergeSortedNumericField
public void mergeSortedNumericField(FieldInfo mergeFieldInfo, MergeState mergeState) throws IOException Merges the sorted docvalues fromtoMerge
.The default implementation calls
addSortedNumericField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
, passing iterables that filter deleted documents.- Throws:
IOException
-
getMergedSortedNumericDocValues
protected static SortedNumericDocValues getMergedSortedNumericDocValues(FieldInfo mergeFieldInfo, MergeState mergeState) throws IOException Returns a merged sorted numeric doc values instance from all producers in the provided merge state.- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
mergeSortedField
Merges the sorted docvalues fromtoMerge
.The default implementation calls
addSortedField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
, passing an Iterable that merges ordinals and values and filters deleted documents .- Throws:
IOException
-
createOrdinalMapForSortedDV
protected static OrdinalMap createOrdinalMapForSortedDV(FieldInfo fieldInfo, MergeState mergeState) throws IOException Returns a merged sorted doc values instance from all producers in the provided merge state.- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
getMergedSortedSetDocValues
protected static SortedDocValues getMergedSortedSetDocValues(FieldInfo fieldInfo, MergeState mergeState, OrdinalMap map) throws IOException Returns a merged sorted doc values instance from all producers in the provided merge state.- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
mergeSortedValues
protected static SortedDocValues mergeSortedValues(List<org.apache.lucene.codecs.DocValuesConsumer.SortedDocValuesSub> subs, MergeState mergeState, OrdinalMap map) throws IOException Returns a merged sorted doc values instance from all producers in the provided merge state.- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
mergeSortedSetField
Merges the sortedset docvalues fromtoMerge
.The default implementation calls
addSortedSetField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.DocValuesProducer)
, passing an Iterable that merges ordinals and values and filters deleted documents .- Throws:
IOException
-
createOrdinalMapForSortedSetDV
protected static OrdinalMap createOrdinalMapForSortedSetDV(List<SortedSetDocValues> toMerge, MergeState mergeState) throws IOException Creates an ordinal map based on the provided sorted set doc values to merges- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
selectLeavesToMerge
protected static List<SortedSetDocValues> selectLeavesToMerge(FieldInfo mergeFieldInfo, MergeState mergeState) throws IOException Selects the sorted set doc values to merge.- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
getMergedSortedSetDocValues
protected static SortedSetDocValues getMergedSortedSetDocValues(FieldInfo mergeFieldInfo, MergeState mergeState, OrdinalMap map, List<SortedSetDocValues> toMerge) throws IOException Returns a sorted set doc values instance from all producers in the provided merge state.- Throws:
IOException
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
isSingleValued
Helper: returns true if the given docToValue count contains only at most one value -
singletonView
public static Iterable<Number> singletonView(Iterable<Number> docToValueCount, Iterable<Number> values, Number missingValue) Helper: returns single-valued view, usingmissingValue
when count is zero
-