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 classDefaultIndexingChain.IntBlockAllocatorprivate classDefaultIndexingChain.PerFieldNOTE: not static: accesses at least docState, termsHash.
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Consumer<java.lang.Throwable>abortingExceptionConsumerprivate ByteBlockPool.AllocatorbyteBlockAllocator(package private) CounterbytesUsedprivate DefaultIndexingChain.PerField[]fieldHash(package private) FieldInfos.BuilderfieldInfosprivate DefaultIndexingChain.PerField[]fieldsprivate booleanhasHitAbortingExceptionprivate inthashMaskprivate intindexCreatedVersionMajorprivate LiveIndexWriterConfigindexWriterConfigprivate InfoStreaminfoStreamprivate longnextFieldGen(package private) StoredFieldsConsumerstoredFieldsConsumer(package private) TermsHashtermsHash(package private) TermVectorsConsumertermVectorsWriterprivate inttotalFieldCount-
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 voidabort()private voidfinishStoredFields()Calls StoredFieldsWriter.finishDocument, aborting the segment if it hits any exception.Sorter.DocMapflush(SegmentWriteState state)java.util.Collection<Accountable>getChildResources()Returns nested resources of this class.private LeafReadergetDocValuesLeafReader()(package private) DocIdSetIteratorgetHasDocValues(java.lang.String field)Returns aDocIdSetIteratorfor the given field or null if the field doesn't have doc values.private DefaultIndexingChain.PerFieldgetOrAddField(java.lang.String name, IndexableFieldType fieldType, boolean invert)Returns a previously createdDefaultIndexingChain.PerField, absorbing the type information fromFieldType, and creates a newDefaultIndexingChain.PerFieldif this field name wasn't seen yet.private DefaultIndexingChain.PerFieldgetPerField(java.lang.String name)Returns a previously createdDefaultIndexingChain.PerField, or null if this field name wasn't seen yet.private voidindexDocValue(int docID, DefaultIndexingChain.PerField fp, DocValuesType dvType, IndexableField field)Called from processDocument to index one field's doc valueprivate voidindexPoint(int docID, DefaultIndexingChain.PerField fp, IndexableField field)Called from processDocument to index one field's pointprivate voidinitIndexOptions(FieldInfo info, IndexOptions indexOptions)private Sorter.DocMapmaybeSortSegment(SegmentWriteState state)private voidonAbortingException(java.lang.Throwable th)voidprocessDocument(int docID, java.lang.Iterable<? extends IndexableField> document)private intprocessField(int docID, IndexableField field, long fieldGen, int fieldCount)longramBytesUsed()Return the memory usage of this object in bytes.private voidrehash()private voidstartStoredFields(int docID)Calls StoredFieldsWriter.startDocument, aborting the segment if it hits any exception.private voidvalidateIndexSortDVType(Sort indexSort, java.lang.String fieldToValidate, DocValuesType dvType)private static voidverifyUnIndexedFieldType(java.lang.String name, IndexableFieldType ft)private voidwriteDocValues(SegmentWriteState state, Sorter.DocMap sortMap)Writes all buffered doc values (called fromflush(org.apache.lucene.index.SegmentWriteState)).private voidwriteNorms(SegmentWriteState state, Sorter.DocMap sortMap)private voidwritePoints(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:
flushin 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:
abortin classDocConsumer- Throws:
java.io.IOException
-
rehash
private void rehash()
-
startStoredFields
private void startStoredFields(int docID) throws java.io.IOExceptionCalls StoredFieldsWriter.startDocument, aborting the segment if it hits any exception.- Throws:
java.io.IOException
-
finishStoredFields
private void finishStoredFields() throws java.io.IOExceptionCalls 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:
processDocumentin 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.IOExceptionCalled 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.PerFieldif this field name wasn't seen yet.
-
initIndexOptions
private void initIndexOptions(FieldInfo info, IndexOptions indexOptions)
-
ramBytesUsed
public long ramBytesUsed()
Description copied from interface:AccountableReturn the memory usage of this object in bytes. Negative values are illegal.
-
getChildResources
public java.util.Collection<Accountable> getChildResources()
Description copied from interface:AccountableReturns 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:DocConsumerReturns aDocIdSetIteratorfor the given field or null if the field doesn't have doc values.- Specified by:
getHasDocValuesin classDocConsumer
-
-