public SepPostingsWriter(SegmentWriteState state, Int32StreamFactory factory, int skipInterval) { freqOut = null; freqIndex = null; posOut = null; posIndex = null; payloadOut = null; bool success = false; try { this.skipInterval = skipInterval; this.skipMinimum = skipInterval; /* set to the same for now */ string docFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, DOC_EXTENSION); docOut = factory.CreateOutput(state.Directory, docFileName, state.Context); docIndex = docOut.GetIndex(); if (state.FieldInfos.HasFreq) { string frqFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, FREQ_EXTENSION); freqOut = factory.CreateOutput(state.Directory, frqFileName, state.Context); freqIndex = freqOut.GetIndex(); } if (state.FieldInfos.HasProx) { string posFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, POS_EXTENSION); posOut = factory.CreateOutput(state.Directory, posFileName, state.Context); posIndex = posOut.GetIndex(); // TODO: -- only if at least one field stores payloads? string payloadFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, PAYLOAD_EXTENSION); payloadOut = state.Directory.CreateOutput(payloadFileName, state.Context); } string skipFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, SKIP_EXTENSION); skipOut = state.Directory.CreateOutput(skipFileName, state.Context); totalNumDocs = state.SegmentInfo.DocCount; skipListWriter = new SepSkipListWriter(skipInterval, maxSkipLevels, totalNumDocs, freqOut, docOut, posOut, payloadOut); success = true; } finally { if (!success) { IOUtils.CloseWhileHandlingException(docOut, skipOut, freqOut, posOut, payloadOut); } } }
public SepPostingsWriter(SegmentWriteState state, IntStreamFactory factory, int skipInterval) { FREQ_OUT = null; FREQ_INDEX = null; POS_OUT = null; POS_INDEX = null; PAYLOAD_OUT = null; var success = false; try { SKIP_INTERVAL = skipInterval; SKIP_MINIMUM = skipInterval; // set to the same for now var docFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, DOC_EXTENSION); DOC_OUT = factory.CreateOutput(state.Directory, docFileName, state.Context); DOC_INDEX = DOC_OUT.Index(); if (state.FieldInfos.HasFreq()) { var frqFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, FREQ_EXTENSION); FREQ_OUT = factory.CreateOutput(state.Directory, frqFileName, state.Context); FREQ_INDEX = FREQ_OUT.Index(); } if (state.FieldInfos.HasProx()) { var posFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, POS_EXTENSION); POS_OUT = factory.CreateOutput(state.Directory, posFileName, state.Context); POS_INDEX = POS_OUT.Index(); // TODO: -- only if at least one field stores payloads? var payloadFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, PAYLOAD_EXTENSION); PAYLOAD_OUT = state.Directory.CreateOutput(payloadFileName, state.Context); } var skipFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, SKIP_EXTENSION); SKIP_OUT = state.Directory.CreateOutput(skipFileName, state.Context); TOTAL_NUM_DOCS = state.SegmentInfo.DocCount; SKIP_LIST_WRITER = new SepSkipListWriter(skipInterval, MAX_SKIP_LEVELS, TOTAL_NUM_DOCS, FREQ_OUT, DOC_OUT, POS_OUT, PAYLOAD_OUT); success = true; } finally { if (!success) { IOUtils.CloseWhileHandlingException(DOC_OUT, SKIP_OUT, FREQ_OUT, POS_OUT, PAYLOAD_OUT); } } }
public SepPostingsWriter(SegmentWriteState state, IntStreamFactory factory, int skipInterval) { FREQ_OUT = null; FREQ_INDEX = null; POS_OUT = null; POS_INDEX = null; PAYLOAD_OUT = null; var success = false; try { SKIP_INTERVAL = skipInterval; SKIP_MINIMUM = skipInterval; // set to the same for now var docFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, DOC_EXTENSION); DOC_OUT = factory.CreateOutput(state.Directory, docFileName, state.Context); DOC_INDEX = DOC_OUT.Index(); if (state.FieldInfos.HasFreq()) { var frqFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, FREQ_EXTENSION); FREQ_OUT = factory.CreateOutput(state.Directory, frqFileName, state.Context); FREQ_INDEX = FREQ_OUT.Index(); } if (state.FieldInfos.HasProx()) { var posFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, POS_EXTENSION); POS_OUT = factory.CreateOutput(state.Directory, posFileName, state.Context); POS_INDEX = POS_OUT.Index(); // TODO: -- only if at least one field stores payloads? var payloadFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix,PAYLOAD_EXTENSION); PAYLOAD_OUT = state.Directory.CreateOutput(payloadFileName, state.Context); } var skipFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, SKIP_EXTENSION); SKIP_OUT = state.Directory.CreateOutput(skipFileName, state.Context); TOTAL_NUM_DOCS = state.SegmentInfo.DocCount; SKIP_LIST_WRITER = new SepSkipListWriter(skipInterval, MAX_SKIP_LEVELS, TOTAL_NUM_DOCS, FREQ_OUT, DOC_OUT, POS_OUT, PAYLOAD_OUT); success = true; } finally { if (!success) { IOUtils.CloseWhileHandlingException(DOC_OUT, SKIP_OUT, FREQ_OUT, POS_OUT, PAYLOAD_OUT); } } }