- java.lang.Object
-
- org.apache.lucene.codecs.DocValuesConsumer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
Lucene70DocValuesConsumer
,Lucene80DocValuesConsumer
,Lucene90DocValuesConsumer
,PerFieldDocValuesFormat.FieldsWriter
,SimpleTextDocValuesWriter
public abstract class DocValuesConsumer extends java.lang.Object implements java.io.Closeable
Abstract API that consumes numeric, binary and sorted docvalues. Concrete implementations of this actually do "something" with the docvalues (write it into the index in a specific format).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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DocValuesConsumer.BinaryDocValuesSub
Tracks state of one binary sub-reader that we are merging(package private) static class
DocValuesConsumer.BitsFilteredTermsEnum
private static class
DocValuesConsumer.MergedTermsEnum
A mergedTermsEnum
.private static class
DocValuesConsumer.NumericDocValuesSub
Tracks state of one numeric sub-reader that we are mergingprivate static class
DocValuesConsumer.SortedDocValuesSub
Tracks state of one sorted sub-reader that we are mergingprivate static class
DocValuesConsumer.SortedNumericDocValuesSub
Tracks state of one sorted numeric sub-reader that we are mergingprivate static class
DocValuesConsumer.SortedSetDocValuesSub
Tracks state of one sorted set sub-reader that we are merging
-
Constructor Summary
Constructors Modifier Constructor Description protected
DocValuesConsumer()
Sole constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract 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 fieldstatic boolean
isSingleValued(java.lang.Iterable<java.lang.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
.private static NumericDocValues
mergeNumericValues(java.util.List<DocValuesConsumer.NumericDocValuesSub> subs, boolean indexIsSorted)
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
.private static SortedDocValues
mergeSortedValues(java.util.List<DocValuesConsumer.SortedDocValuesSub> subs, boolean indexIsSorted, OrdinalMap map)
static java.lang.Iterable<java.lang.Number>
singletonView(java.lang.Iterable<java.lang.Number> docToValueCount, java.lang.Iterable<java.lang.Number> values, java.lang.Number missingValue)
Helper: returns single-valued view, usingmissingValue
when count is zero
-
-
-
Method Detail
-
addNumericField
public abstract void addNumericField(FieldInfo field, DocValuesProducer valuesProducer) throws java.io.IOException
Writes numeric docvalues for a field.- Parameters:
field
- field informationvaluesProducer
- Numeric values to write.- Throws:
java.io.IOException
- if an I/O error occurred.
-
addBinaryField
public abstract void addBinaryField(FieldInfo field, DocValuesProducer valuesProducer) throws java.io.IOException
Writes binary docvalues for a field.- Parameters:
field
- field informationvaluesProducer
- Binary values to write.- Throws:
java.io.IOException
- if an I/O error occurred.
-
addSortedField
public abstract void addSortedField(FieldInfo field, DocValuesProducer valuesProducer) throws java.io.IOException
Writes pre-sorted binary docvalues for a field.- Parameters:
field
- field informationvaluesProducer
- produces the values and ordinals to write- Throws:
java.io.IOException
- if an I/O error occurred.
-
addSortedNumericField
public abstract void addSortedNumericField(FieldInfo field, DocValuesProducer valuesProducer) throws java.io.IOException
Writes pre-sorted numeric docvalues for a field- Parameters:
field
- field informationvaluesProducer
- produces the values to write- Throws:
java.io.IOException
- if an I/O error occurred.
-
addSortedSetField
public abstract void addSortedSetField(FieldInfo field, DocValuesProducer valuesProducer) throws java.io.IOException
Writes pre-sorted set docvalues for a field- Parameters:
field
- field informationvaluesProducer
- produces the values to write- Throws:
java.io.IOException
- if an I/O error occurred.
-
merge
public void merge(MergeState mergeState) throws java.io.IOException
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:
java.io.IOException
-
mergeNumericField
public void mergeNumericField(FieldInfo mergeFieldInfo, MergeState mergeState) throws java.io.IOException
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:
java.io.IOException
-
mergeNumericValues
private static NumericDocValues mergeNumericValues(java.util.List<DocValuesConsumer.NumericDocValuesSub> subs, boolean indexIsSorted) throws java.io.IOException
- Throws:
java.io.IOException
-
mergeBinaryField
public void mergeBinaryField(FieldInfo mergeFieldInfo, MergeState mergeState) throws java.io.IOException
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:
java.io.IOException
-
mergeSortedNumericField
public void mergeSortedNumericField(FieldInfo mergeFieldInfo, MergeState mergeState) throws java.io.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:
java.io.IOException
-
mergeSortedField
public void mergeSortedField(FieldInfo fieldInfo, MergeState mergeState) throws java.io.IOException
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:
java.io.IOException
-
mergeSortedValues
private static SortedDocValues mergeSortedValues(java.util.List<DocValuesConsumer.SortedDocValuesSub> subs, boolean indexIsSorted, OrdinalMap map) throws java.io.IOException
- Throws:
java.io.IOException
-
mergeSortedSetField
public void mergeSortedSetField(FieldInfo mergeFieldInfo, MergeState mergeState) throws java.io.IOException
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:
java.io.IOException
-
isSingleValued
public static boolean isSingleValued(java.lang.Iterable<java.lang.Number> docToValueCount)
Helper: returns true if the given docToValue count contains only at most one value
-
singletonView
public static java.lang.Iterable<java.lang.Number> singletonView(java.lang.Iterable<java.lang.Number> docToValueCount, java.lang.Iterable<java.lang.Number> values, java.lang.Number missingValue)
Helper: returns single-valued view, usingmissingValue
when count is zero
-
-