Package org.apache.lucene.index
Class DefaultIndexingChain
- java.lang.Object
-
- org.apache.lucene.index.DocConsumer
-
- org.apache.lucene.index.DefaultIndexingChain
-
- All Implemented Interfaces:
Accountable
final class DefaultIndexingChain extends DocConsumer
Default general purpose indexing chain, which handles indexing all types of fields.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DefaultIndexingChain.IntBlockAllocator
private class
DefaultIndexingChain.PerField
NOTE: not static: accesses at least docState, termsHash.
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Consumer<java.lang.Throwable>
abortingExceptionConsumer
private ByteBlockPool.Allocator
byteBlockAllocator
(package private) Counter
bytesUsed
private DefaultIndexingChain.PerField[]
fieldHash
(package private) FieldInfos.Builder
fieldInfos
private DefaultIndexingChain.PerField[]
fields
private boolean
hasHitAbortingException
private int
hashMask
private int
indexCreatedVersionMajor
private LiveIndexWriterConfig
indexWriterConfig
private InfoStream
infoStream
private long
nextFieldGen
(package private) StoredFieldsConsumer
storedFieldsConsumer
(package private) TermsHash
termsHash
(package private) TermVectorsConsumer
termVectorsWriter
private int
totalFieldCount
-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Constructor Summary
Constructors Constructor Description DefaultIndexingChain(int indexCreatedVersionMajor, SegmentInfo segmentInfo, Directory directory, FieldInfos.Builder fieldInfos, LiveIndexWriterConfig indexWriterConfig, java.util.function.Consumer<java.lang.Throwable> abortingExceptionConsumer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
private void
finishStoredFields()
Calls StoredFieldsWriter.finishDocument, aborting the segment if it hits any exception.Sorter.DocMap
flush(SegmentWriteState state)
java.util.Collection<Accountable>
getChildResources()
Returns nested resources of this class.private LeafReader
getDocValuesLeafReader()
(package private) DocIdSetIterator
getHasDocValues(java.lang.String field)
Returns aDocIdSetIterator
for the given field or null if the field doesn't have doc values.private DefaultIndexingChain.PerField
getOrAddField(java.lang.String name, IndexableFieldType fieldType, boolean invert)
Returns a previously createdDefaultIndexingChain.PerField
, absorbing the type information fromFieldType
, and creates a newDefaultIndexingChain.PerField
if this field name wasn't seen yet.private DefaultIndexingChain.PerField
getPerField(java.lang.String name)
Returns a previously createdDefaultIndexingChain.PerField
, or null if this field name wasn't seen yet.private void
indexDocValue(int docID, DefaultIndexingChain.PerField fp, DocValuesType dvType, IndexableField field)
Called from processDocument to index one field's doc valueprivate void
indexPoint(int docID, DefaultIndexingChain.PerField fp, IndexableField field)
Called from processDocument to index one field's pointprivate void
initIndexOptions(FieldInfo info, IndexOptions indexOptions)
private Sorter.DocMap
maybeSortSegment(SegmentWriteState state)
private void
onAbortingException(java.lang.Throwable th)
void
processDocument(int docID, java.lang.Iterable<? extends IndexableField> document)
private int
processField(int docID, IndexableField field, long fieldGen, int fieldCount)
long
ramBytesUsed()
Return the memory usage of this object in bytes.private void
rehash()
private void
startStoredFields(int docID)
Calls StoredFieldsWriter.startDocument, aborting the segment if it hits any exception.private void
validateIndexSortDVType(Sort indexSort, java.lang.String fieldToValidate, DocValuesType dvType)
private static void
verifyUnIndexedFieldType(java.lang.String name, IndexableFieldType ft)
private void
writeDocValues(SegmentWriteState state, Sorter.DocMap sortMap)
Writes all buffered doc values (called fromflush(org.apache.lucene.index.SegmentWriteState)
).private void
writeNorms(SegmentWriteState state, Sorter.DocMap sortMap)
private void
writePoints(SegmentWriteState state, Sorter.DocMap sortMap)
Writes all buffered points.
-
-
-
Field Detail
-
bytesUsed
final Counter bytesUsed
-
fieldInfos
final FieldInfos.Builder fieldInfos
-
termsHash
final TermsHash termsHash
-
storedFieldsConsumer
final StoredFieldsConsumer storedFieldsConsumer
-
termVectorsWriter
final TermVectorsConsumer termVectorsWriter
-
fieldHash
private DefaultIndexingChain.PerField[] fieldHash
-
hashMask
private int hashMask
-
totalFieldCount
private int totalFieldCount
-
nextFieldGen
private long nextFieldGen
-
fields
private DefaultIndexingChain.PerField[] fields
-
infoStream
private final InfoStream infoStream
-
byteBlockAllocator
private final ByteBlockPool.Allocator byteBlockAllocator
-
indexWriterConfig
private final LiveIndexWriterConfig indexWriterConfig
-
indexCreatedVersionMajor
private final int indexCreatedVersionMajor
-
abortingExceptionConsumer
private final java.util.function.Consumer<java.lang.Throwable> abortingExceptionConsumer
-
hasHitAbortingException
private boolean hasHitAbortingException
-
-
Constructor Detail
-
DefaultIndexingChain
DefaultIndexingChain(int indexCreatedVersionMajor, SegmentInfo segmentInfo, Directory directory, FieldInfos.Builder fieldInfos, LiveIndexWriterConfig indexWriterConfig, java.util.function.Consumer<java.lang.Throwable> abortingExceptionConsumer)
-
-
Method Detail
-
onAbortingException
private void onAbortingException(java.lang.Throwable th)
-
getDocValuesLeafReader
private LeafReader getDocValuesLeafReader()
-
maybeSortSegment
private Sorter.DocMap maybeSortSegment(SegmentWriteState state) throws java.io.IOException
- Throws:
java.io.IOException
-
flush
public Sorter.DocMap flush(SegmentWriteState state) throws java.io.IOException
- Specified by:
flush
in classDocConsumer
- Throws:
java.io.IOException
-
writePoints
private void writePoints(SegmentWriteState state, Sorter.DocMap sortMap) throws java.io.IOException
Writes all buffered points.- Throws:
java.io.IOException
-
writeDocValues
private void writeDocValues(SegmentWriteState state, Sorter.DocMap sortMap) throws java.io.IOException
Writes all buffered doc values (called fromflush(org.apache.lucene.index.SegmentWriteState)
).- Throws:
java.io.IOException
-
writeNorms
private void writeNorms(SegmentWriteState state, Sorter.DocMap sortMap) throws java.io.IOException
- Throws:
java.io.IOException
-
abort
public void abort() throws java.io.IOException
- Specified by:
abort
in classDocConsumer
- Throws:
java.io.IOException
-
rehash
private void rehash()
-
startStoredFields
private void startStoredFields(int docID) throws java.io.IOException
Calls StoredFieldsWriter.startDocument, aborting the segment if it hits any exception.- Throws:
java.io.IOException
-
finishStoredFields
private void finishStoredFields() throws java.io.IOException
Calls StoredFieldsWriter.finishDocument, aborting the segment if it hits any exception.- Throws:
java.io.IOException
-
processDocument
public void processDocument(int docID, java.lang.Iterable<? extends IndexableField> document) throws java.io.IOException
- Specified by:
processDocument
in classDocConsumer
- Throws:
java.io.IOException
-
processField
private int processField(int docID, IndexableField field, long fieldGen, int fieldCount) throws java.io.IOException
- Throws:
java.io.IOException
-
verifyUnIndexedFieldType
private static void verifyUnIndexedFieldType(java.lang.String name, IndexableFieldType ft)
-
indexPoint
private void indexPoint(int docID, DefaultIndexingChain.PerField fp, IndexableField field)
Called from processDocument to index one field's point
-
validateIndexSortDVType
private void validateIndexSortDVType(Sort indexSort, java.lang.String fieldToValidate, DocValuesType dvType) throws java.io.IOException
- Throws:
java.io.IOException
-
indexDocValue
private void indexDocValue(int docID, DefaultIndexingChain.PerField fp, DocValuesType dvType, IndexableField field) throws java.io.IOException
Called from processDocument to index one field's doc value- Throws:
java.io.IOException
-
getPerField
private DefaultIndexingChain.PerField getPerField(java.lang.String name)
Returns a previously createdDefaultIndexingChain.PerField
, or null if this field name wasn't seen yet.
-
getOrAddField
private DefaultIndexingChain.PerField getOrAddField(java.lang.String name, IndexableFieldType fieldType, boolean invert)
Returns a previously createdDefaultIndexingChain.PerField
, absorbing the type information fromFieldType
, and creates a newDefaultIndexingChain.PerField
if this field name wasn't seen yet.
-
initIndexOptions
private void initIndexOptions(FieldInfo info, IndexOptions indexOptions)
-
ramBytesUsed
public long ramBytesUsed()
Description copied from interface:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.
-
getChildResources
public java.util.Collection<Accountable> getChildResources()
Description copied from interface:Accountable
Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).- See Also:
Accountables
-
getHasDocValues
DocIdSetIterator getHasDocValues(java.lang.String field)
Description copied from class:DocConsumer
Returns aDocIdSetIterator
for the given field or null if the field doesn't have doc values.- Specified by:
getHasDocValues
in classDocConsumer
-
-