Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
	attributes, err := input.ReadStringStringMap()
	if err != nil {
		return si, err
	}
	files, err := input.ReadStringSet()
	if err != nil {
		return si, err
	}

	if input.FilePointer() != input.Length() {
		return si, errors.New(fmt.Sprintf(
			"did not read all bytes from file '%v': read %v vs size %v (resource: %v)",
			fileName, input.FilePointer(), input.Length(), input))
	}

	si = model.NewSegmentInfo(dir, version, segment, int(docCount), isCompoundFile,
		nil, diagnostics, attributes)
	si.SetFiles(files)

	success = true
	return si, nil
}

// lucene40/Lucne40SegmentInfoWriter.java

// Lucene 4.0 implementation of SegmentInfoWriter
var Lucene40SegmentInfoWriter = func(dir store.Directory,
	si *model.SegmentInfo, fis model.FieldInfos, ctx store.IOContext) error {

	panic("not implemented yet")
}