func newDocumentsWriterPerThread(segmentName string, directory store.Directory, indexWriterConfig *LiveIndexWriterConfig, infoStream util.InfoStream, deleteQueue *DocumentsWriterDeleteQueue, fieldInfos *model.FieldInfosBuilder) *DocumentsWriterPerThread { counter := util.NewCounter() ans := &DocumentsWriterPerThread{ directoryOrig: directory, directory: store.NewTrackingDirectoryWrapper(directory), fieldInfos: fieldInfos, indexWriterConfig: indexWriterConfig, infoStream: infoStream, codec: indexWriterConfig.codec, _bytesUsed: counter, byteBlockAllocator: util.NewDirectTrackingAllocator(counter), pendingDeletes: newBufferedDeletes(), intBlockAllocator: newIntBlockAllocator(counter), deleteQueue: deleteQueue, deleteSlice: deleteQueue.newSlice(), segmentInfo: model.NewSegmentInfo(directory, util.LUCENE_MAIN_VERSION, segmentName, -1, false, indexWriterConfig.codec, nil, nil), filesToDelete: make(map[string]bool), } ans.docState = newDocState(ans, infoStream) ans.docState.similarity = indexWriterConfig.similarity assertn(ans.numDocsInRAM == 0, "num docs ", ans.numDocsInRAM) if DWPT_VERBOSE && infoStream.IsEnabled("DWPT") { infoStream.Message("DWPT", "init seg=%v delQueue=%v", segmentName, deleteQueue) } // this should be the last call in the ctor // it really sucks that we need to pull this within the ctor and pass this ref to the chain! ans.consumer = indexWriterConfig.indexingChain(ans) return ans }
func newTermsHash(spi TermsHashImplSPI, docWriter *DocumentsWriterPerThread, trackAllocations bool, nextTermsHash TermsHash) *TermsHashImpl { ans := &TermsHashImpl{ spi: spi, docState: docWriter.docState, trackAllocations: trackAllocations, nextTermsHash: nextTermsHash, intPool: util.NewIntBlockPool(docWriter.intBlockAllocator), bytePool: util.NewByteBlockPool(docWriter.byteBlockAllocator), } if trackAllocations { ans.bytesUsed = docWriter._bytesUsed } else { ans.bytesUsed = util.NewCounter() } if nextTermsHash != nil { ans.termBytePool = ans.bytePool nextTermsHash.setTermBytePool(ans.bytePool) } return ans }
func newTermsHash(docWriter *DocumentsWriterPerThread, consumer TermsHashConsumer, trackAllocations bool, nextTermsHash *TermsHash) *TermsHash { ans := &TermsHash{ docState: docWriter.docState, consumer: consumer, trackAllocations: trackAllocations, nextTermsHash: nextTermsHash, intPool: util.NewIntBlockPool(docWriter.intBlockAllocator), bytePool: util.NewByteBlockPool(docWriter.byteBlockAllocator), } if trackAllocations { ans.bytesUsed = docWriter._bytesUsed } else { ans.bytesUsed = util.NewCounter() } ans.primary = nextTermsHash != nil if ans.primary { ans.termBytePool = ans.bytePool nextTermsHash.termBytePool = ans.bytePool } return ans }