Пример #1
0
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
}
Пример #2
0
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
}