Class DocValuesConsumer
- java.lang.Object
-
- org.apache.lucene.codecs.DocValuesConsumer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
Lucene45DocValuesConsumer
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)
orNormsFormat.normsConsumer(SegmentWriteState)
. addNumericField(org.apache.lucene.index.FieldInfo, java.lang.Iterable<java.lang.Number>)
,addBinaryField(org.apache.lucene.index.FieldInfo, java.lang.Iterable<org.apache.lucene.util.BytesRef>)
, oraddSortedField(org.apache.lucene.index.FieldInfo, java.lang.Iterable<org.apache.lucene.util.BytesRef>, java.lang.Iterable<java.lang.Number>)
are called for each Numeric, Binary, or Sorted 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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addBinaryField(FieldInfo field, java.lang.Iterable<BytesRef> values)
Writes binary docvalues for a field.abstract void
addNumericField(FieldInfo field, java.lang.Iterable<java.lang.Number> values)
Writes numeric docvalues for a field.abstract void
addSortedField(FieldInfo field, java.lang.Iterable<BytesRef> values, java.lang.Iterable<java.lang.Number> docToOrd)
Writes pre-sorted binary docvalues for a field.abstract void
addSortedSetField(FieldInfo field, java.lang.Iterable<BytesRef> values, java.lang.Iterable<java.lang.Number> docToOrdCount, java.lang.Iterable<java.lang.Number> ords)
Writes pre-sorted set docvalues for a fieldvoid
mergeBinaryField(FieldInfo fieldInfo, MergeState mergeState, java.util.List<BinaryDocValues> toMerge, java.util.List<Bits> docsWithField)
Merges the binary docvalues fromtoMerge
.void
mergeNumericField(FieldInfo fieldInfo, MergeState mergeState, java.util.List<NumericDocValues> toMerge, java.util.List<Bits> docsWithField)
Merges the numeric docvalues fromtoMerge
.void
mergeSortedField(FieldInfo fieldInfo, MergeState mergeState, java.util.List<SortedDocValues> toMerge)
Merges the sorted docvalues fromtoMerge
.void
mergeSortedSetField(FieldInfo fieldInfo, MergeState mergeState, java.util.List<SortedSetDocValues> toMerge)
Merges the sortedset docvalues fromtoMerge
.
-
-
-
Method Detail
-
addNumericField
public abstract void addNumericField(FieldInfo field, java.lang.Iterable<java.lang.Number> values) throws java.io.IOException
Writes numeric docvalues for a field.- Parameters:
field
- field informationvalues
- Iterable of numeric values (one for each document).null
indicates a missing value.- Throws:
java.io.IOException
- if an I/O error occurred.
-
addBinaryField
public abstract void addBinaryField(FieldInfo field, java.lang.Iterable<BytesRef> values) throws java.io.IOException
Writes binary docvalues for a field.- Parameters:
field
- field informationvalues
- Iterable of binary values (one for each document).null
indicates a missing value.- Throws:
java.io.IOException
- if an I/O error occurred.
-
addSortedField
public abstract void addSortedField(FieldInfo field, java.lang.Iterable<BytesRef> values, java.lang.Iterable<java.lang.Number> docToOrd) throws java.io.IOException
Writes pre-sorted binary docvalues for a field.- Parameters:
field
- field informationvalues
- Iterable of binary values in sorted order (deduplicated).docToOrd
- Iterable of ordinals (one for each document).-1
indicates a missing value.- Throws:
java.io.IOException
- if an I/O error occurred.
-
addSortedSetField
public abstract void addSortedSetField(FieldInfo field, java.lang.Iterable<BytesRef> values, java.lang.Iterable<java.lang.Number> docToOrdCount, java.lang.Iterable<java.lang.Number> ords) throws java.io.IOException
Writes pre-sorted set docvalues for a field- Parameters:
field
- field informationvalues
- Iterable of binary values in sorted order (deduplicated).docToOrdCount
- Iterable of the number of values for each document. A zero ordinal count indicates a missing value.ords
- Iterable of ordinal occurrences (docToOrdCount*maxDoc total).- Throws:
java.io.IOException
- if an I/O error occurred.
-
mergeNumericField
public void mergeNumericField(FieldInfo fieldInfo, MergeState mergeState, java.util.List<NumericDocValues> toMerge, java.util.List<Bits> docsWithField) throws java.io.IOException
Merges the numeric docvalues fromtoMerge
.The default implementation calls
addNumericField(org.apache.lucene.index.FieldInfo, java.lang.Iterable<java.lang.Number>)
, passing an Iterable that merges and filters deleted documents on the fly.- Throws:
java.io.IOException
-
mergeBinaryField
public void mergeBinaryField(FieldInfo fieldInfo, MergeState mergeState, java.util.List<BinaryDocValues> toMerge, java.util.List<Bits> docsWithField) throws java.io.IOException
Merges the binary docvalues fromtoMerge
.The default implementation calls
addBinaryField(org.apache.lucene.index.FieldInfo, java.lang.Iterable<org.apache.lucene.util.BytesRef>)
, passing an Iterable that merges and filters deleted documents on the fly.- Throws:
java.io.IOException
-
mergeSortedField
public void mergeSortedField(FieldInfo fieldInfo, MergeState mergeState, java.util.List<SortedDocValues> toMerge) throws java.io.IOException
Merges the sorted docvalues fromtoMerge
.The default implementation calls
addSortedField(org.apache.lucene.index.FieldInfo, java.lang.Iterable<org.apache.lucene.util.BytesRef>, java.lang.Iterable<java.lang.Number>)
, passing an Iterable that merges ordinals and values and filters deleted documents .- Throws:
java.io.IOException
-
mergeSortedSetField
public void mergeSortedSetField(FieldInfo fieldInfo, MergeState mergeState, java.util.List<SortedSetDocValues> toMerge) throws java.io.IOException
Merges the sortedset docvalues fromtoMerge
.The default implementation calls
addSortedSetField(org.apache.lucene.index.FieldInfo, java.lang.Iterable<org.apache.lucene.util.BytesRef>, java.lang.Iterable<java.lang.Number>, java.lang.Iterable<java.lang.Number>)
, passing an Iterable that merges ordinals and values and filters deleted documents .- Throws:
java.io.IOException
-
-