/// <summary> /// Creates a <seealso cref="Lucene40PostingsWriter"/>, with the /// specified {@code skipInterval}. /// </summary> public Lucene40PostingsWriter(SegmentWriteState state, int skipInterval) : base() { this.SkipInterval = skipInterval; this.SkipMinimum = skipInterval; // set to the same for now // this.segment = state.segmentName; string fileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, Lucene40PostingsFormat.FREQ_EXTENSION); FreqOut = state.Directory.CreateOutput(fileName, state.Context); bool success = false; IndexOutput proxOut = null; try { CodecUtil.WriteHeader(FreqOut, Lucene40PostingsReader.FRQ_CODEC, Lucene40PostingsReader.VERSION_CURRENT); // TODO: this is a best effort, if one of these fields has no postings // then we make an empty prx file, same as if we are wrapped in // per-field postingsformat. maybe... we shouldn't // bother w/ this opto? just create empty prx file...? if (state.FieldInfos.HasProx()) { // At least one field does not omit TF, so create the // prox file fileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, Lucene40PostingsFormat.PROX_EXTENSION); proxOut = state.Directory.CreateOutput(fileName, state.Context); CodecUtil.WriteHeader(proxOut, Lucene40PostingsReader.PRX_CODEC, Lucene40PostingsReader.VERSION_CURRENT); } else { // Every field omits TF so we will write no prox file proxOut = null; } this.ProxOut = proxOut; success = true; } finally { if (!success) { IOUtils.CloseWhileHandlingException(FreqOut, proxOut); } } TotalNumDocs = state.SegmentInfo.DocCount; SkipListWriter = new Lucene40SkipListWriter(skipInterval, MaxSkipLevels, TotalNumDocs, FreqOut, proxOut); }