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.DisposeWhileHandlingException(docOut, skipOut, freqOut, posOut, payloadOut); } } }