public override void CopyFrom(IntIndexOutputIndex other, bool copyLast) { fp = ((MockSingleIntIndexOutputIndex)other).fp; if (copyLast) { lastFP = ((MockSingleIntIndexOutputIndex)other).fp; } }
public override void CopyFrom(IntIndexOutputIndex other, bool copyLast) { OutputIndex idx = (OutputIndex)other; fp = idx.fp; upto = idx.upto; if (copyLast) { lastFP = fp; lastUpto = upto; } }
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); } } }
/// <summary> /// Called @ start of new term /// </summary> protected internal virtual void ResetSkip(IntIndexOutputIndex topDocIndex, IntIndexOutputIndex topFreqIndex, IntIndexOutputIndex topPosIndex) { base.ResetSkip(); Arrays.Fill(_lastSkipDoc, 0); Arrays.Fill(_lastSkipPayloadLength, -1); // we don't have to write the first length in the skip list for (int i = 0; i < NumberOfSkipLevels; i++) { _docIndex[i].CopyFrom(topDocIndex, true); if (_freqOutput != null) { _freqIndex[i].CopyFrom(topFreqIndex, true); } if (_posOutput != null) { _posIndex[i].CopyFrom(topPosIndex, true); } } if (_payloadOutput != null) { Arrays.Fill(_lastSkipPayloadPointer, _payloadOutput.FilePointer); } }
/// <summary>Copies index from other </summary> public abstract void CopyFrom(IntIndexOutputIndex other, bool copyLast);
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); } } }