Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        // Called @ start of new term
        /// <exception cref="IOException"/>
        protected internal void ResetSkip(Int32IndexOutput.Index topDocIndex, Int32IndexOutput.Index topFreqIndex, Int32IndexOutput.Index 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 < m_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.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called @ start of new term.
        /// </summary>
        protected internal virtual void ResetSkip(Int32IndexOutput.Index topDocIndex, Int32IndexOutput.Index topFreqIndex,
                                                  Int32IndexOutput.Index 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 < m_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.GetFilePointer());
            }
        }