Example #1
0
	    internal SepSkipListWriter(int skipInterval, int numberOfSkipLevels, int docCount, IntIndexOutput freqOutput,
	        IntIndexOutput docOutput, IntIndexOutput posOutput, IndexOutput payloadOutput)
	        : base(skipInterval, numberOfSkipLevels, docCount)
	    {

	        _freqOutput = freqOutput;
	        _posOutput = posOutput;
	        _payloadOutput = payloadOutput;

	        _lastSkipDoc = new int[numberOfSkipLevels];
	        _lastSkipPayloadLength = new int[numberOfSkipLevels];
	        // TODO: -- also cutover normal IndexOutput to use getIndex()?
	        _lastSkipPayloadPointer = new long[numberOfSkipLevels];

	        _freqIndex = new IntIndexOutputIndex[numberOfSkipLevels];
	        _docIndex = new IntIndexOutputIndex[numberOfSkipLevels];
	        _posIndex = new IntIndexOutputIndex[numberOfSkipLevels];

	        for (var i = 0; i < numberOfSkipLevels; i++)
	        {
	            if (freqOutput != null)
	            {
	                _freqIndex[i] = freqOutput.Index();
	            }
	            _docIndex[i] = docOutput.Index();
	            if (posOutput != null)
	            {
	                _posIndex[i] = posOutput.Index();
	            }
	        }
	    }
Example #2
0
        internal SepSkipListWriter(int skipInterval, int numberOfSkipLevels, int docCount, IntIndexOutput freqOutput,
                                   IntIndexOutput docOutput, IntIndexOutput posOutput, IndexOutput payloadOutput)
            : base(skipInterval, numberOfSkipLevels, docCount)
        {
            _freqOutput    = freqOutput;
            _posOutput     = posOutput;
            _payloadOutput = payloadOutput;

            _lastSkipDoc           = new int[numberOfSkipLevels];
            _lastSkipPayloadLength = new int[numberOfSkipLevels];
            // TODO: -- also cutover normal IndexOutput to use getIndex()?
            _lastSkipPayloadPointer = new long[numberOfSkipLevels];

            _freqIndex = new IntIndexOutputIndex[numberOfSkipLevels];
            _docIndex  = new IntIndexOutputIndex[numberOfSkipLevels];
            _posIndex  = new IntIndexOutputIndex[numberOfSkipLevels];

            for (var i = 0; i < numberOfSkipLevels; i++)
            {
                if (freqOutput != null)
                {
                    _freqIndex[i] = freqOutput.Index();
                }
                _docIndex[i] = docOutput.Index();
                if (posOutput != null)
                {
                    _posIndex[i] = posOutput.Index();
                }
            }
        }
Example #3
0
        private SepTermState SetEmptyState()
        {
            var emptyState = new SepTermState {
                DocIndex = DOC_OUT.Index()
            };

            if (INDEX_OPTIONS != FieldInfo.IndexOptions.DOCS_ONLY)
            {
                emptyState.FreqIndex = FREQ_OUT.Index();
                if (INDEX_OPTIONS == FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
                {
                    emptyState.PosIndex = POS_OUT.Index();
                }
            }
            emptyState.PayloadFp = 0;
            emptyState.SkipFp    = 0;
            return(emptyState);
        }
Example #4
0
        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);
                }
            }
        }
Example #5
0
        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);
                }
            }
        }