Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
0
        public SepPostingsReader(Directory dir, FieldInfos fieldInfos, SegmentInfo segmentInfo, IOContext context,
                                 IntStreamFactory intFactory, string segmentSuffix)
        {
            var success = false;

            try
            {
                var docFileName = IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix,
                                                                 SepPostingsWriter.DOC_EXTENSION);
                _docIn = intFactory.OpenInput(dir, docFileName, context);

                _skipIn =
                    dir.OpenInput(
                        IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix, SepPostingsWriter.SKIP_EXTENSION),
                        context);

                if (fieldInfos.HasFreq())
                {
                    _freqIn = intFactory.OpenInput(dir,
                                                   IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix, SepPostingsWriter.FREQ_EXTENSION),
                                                   context);
                }
                else
                {
                    _freqIn = null;
                }
                if (fieldInfos.HasProx())
                {
                    _posIn = intFactory.OpenInput(dir,
                                                  IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix, SepPostingsWriter.POS_EXTENSION),
                                                  context);
                    _payloadIn =
                        dir.OpenInput(
                            IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix,
                                                           SepPostingsWriter.PAYLOAD_EXTENSION), context);
                }
                else
                {
                    _posIn     = null;
                    _payloadIn = null;
                }
                success = true;
            }
            finally
            {
                if (!success)
                {
                    Dispose();
                }
            }
        }
Exemplo n.º 3
0
        public SepPostingsReader(Directory dir, FieldInfos fieldInfos, SegmentInfo segmentInfo, IOContext context,
            IntStreamFactory intFactory, string segmentSuffix)
        {
            var success = false;
            try
            {

                var docFileName = IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix,
                    SepPostingsWriter.DOC_EXTENSION);
                _docIn = intFactory.OpenInput(dir, docFileName, context);

                _skipIn =
                    dir.OpenInput(
                        IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix, SepPostingsWriter.SKIP_EXTENSION),
                        context);

                if (fieldInfos.HasFreq())
                {
                    _freqIn = intFactory.OpenInput(dir,
                        IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix, SepPostingsWriter.FREQ_EXTENSION),
                        context);
                }
                else
                {
                    _freqIn = null;
                }
                if (fieldInfos.HasProx())
                {
                    _posIn = intFactory.OpenInput(dir,
                        IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix, SepPostingsWriter.POS_EXTENSION),
                        context);
                    _payloadIn =
                        dir.OpenInput(
                            IndexFileNames.SegmentFileName(segmentInfo.Name, segmentSuffix,
                                SepPostingsWriter.PAYLOAD_EXTENSION), context);
                }
                else
                {
                    _posIn = null;
                    _payloadIn = null;
                }
                success = true;
            }
            finally
            {
                if (!success)
                {
                    Dispose();
                }
            }
        }
Exemplo n.º 4
0
 public SepPostingsWriter(SegmentWriteState state, IntStreamFactory factory)
     : this(state, factory, DEFAULT_SKIP_INTERVAL)
 {
 }
Exemplo n.º 5
0
 public SepPostingsWriter(SegmentWriteState state, IntStreamFactory factory)
     : this(state, factory, DEFAULT_SKIP_INTERVAL)
 {
 }
Exemplo n.º 6
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);
                }
            }
        }