public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
        {
            PostingsWriterBase docsWriter = null;
            PostingsWriterBase pulsingWriterInner = null;
            PostingsWriterBase pulsingWriter = null;

            // Terms dict
            bool success = false;
            try
            {
                docsWriter = new Lucene41PostingsWriter(state);

                pulsingWriterInner = new PulsingPostingsWriter(state, 2, docsWriter);
                pulsingWriter = new PulsingPostingsWriter(state, 1, pulsingWriterInner);
                FieldsConsumer ret = new BlockTreeTermsWriter(state, pulsingWriter,
                    BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
                success = true;
                return ret;
            }
            finally
            {
                if (!success)
                {
                    IOUtils.CloseWhileHandlingException(docsWriter, pulsingWriterInner, pulsingWriter);
                }
            }
        }
Пример #2
0
        public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
        {
            PostingsWriterBase docs = new Lucene41PostingsWriter(state);

            // TODO: should we make the terms index more easily
            // pluggable?  Ie so that this codec would record which
            // index impl was used, and switch on loading?
            // Or... you must make a new Codec for this?
            TermsIndexWriterBase indexWriter;
            bool success = false;
            try
            {
                indexWriter = new FixedGapTermsIndexWriter(state);
                success = true;
            }
            finally
            {
                if (!success)
                {
                    docs.Dispose();
                }
            }

            success = false;
            try
            {
                // Must use BlockTermsWriter (not BlockTree) because
                // BlockTree doens't support ords (yet)...
                FieldsConsumer ret = new BlockTermsWriter(indexWriter, state, docs);
                success = true;
                return ret;
            }
            finally
            {
                if (!success)
                {
                    try
                    {
                        docs.Dispose();
                    }
                    finally
                    {
                        indexWriter.Dispose();
                    }
                }
            }
        }
Пример #3
0
        public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
        {
            PostingsWriterBase postingsWriter = new Lucene41PostingsWriter(state);

            bool success = false;

            try
            {
                FieldsConsumer ret = new BlockTreeTermsWriter(state, postingsWriter, MinTermBlockSize, MaxTermBlockSize);
                success = true;
                return(ret);
            }
            finally
            {
                if (!success)
                {
                    IOUtils.CloseWhileHandlingException(postingsWriter);
                }
            }
        }
Пример #4
0
        public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
        {
            PostingsWriterBase postingsWriter = new Lucene41PostingsWriter(state);

            bool success = false;
            try
            {
                FieldsConsumer ret = new BlockTreeTermsWriter(state, postingsWriter, MinTermBlockSize, MaxTermBlockSize);
                success = true;
                return ret;
            }
            finally
            {
                if (!success)
                {
                    IOUtils.CloseWhileHandlingException(postingsWriter);
                }
            }
        }
Пример #5
0
            public DocsAndPositionsEnum Reset(Bits liveDocs, Lucene41PostingsWriter.IntBlockTermState termState)
            {
                this.LiveDocs = liveDocs;
                // if (DEBUG) {
                //   System.out.println("  FPR.reset: termState=" + termState);
                // }
                DocFreq = termState.DocFreq;
                DocTermStartFP = termState.DocStartFP;
                PosTermStartFP = termState.PosStartFP;
                PayTermStartFP = termState.PayStartFP;
                SkipOffset = termState.SkipOffset;
                TotalTermFreq = termState.TotalTermFreq;
                SingletonDocID = termState.SingletonDocID;
                if (DocFreq > 1)
                {
                    if (DocIn == null)
                    {
                        // lazy init
                        DocIn = (IndexInput)StartDocIn.Clone();
                    }
                    DocIn.Seek(DocTermStartFP);
                }
                PosPendingFP = PosTermStartFP;
                PosPendingCount = 0;
                if (termState.TotalTermFreq < Lucene41PostingsFormat.BLOCK_SIZE)
                {
                    LastPosBlockFP = PosTermStartFP;
                }
                else if (termState.TotalTermFreq == Lucene41PostingsFormat.BLOCK_SIZE)
                {
                    LastPosBlockFP = -1;
                }
                else
                {
                    LastPosBlockFP = PosTermStartFP + termState.LastPosBlockOffset;
                }

                Doc = -1;
                Accum = 0;
                DocUpto = 0;
                NextSkipDoc = Lucene41PostingsFormat.BLOCK_SIZE - 1;
                DocBufferUpto = Lucene41PostingsFormat.BLOCK_SIZE;
                Skipped = false;
                return this;
            }
Пример #6
0
 private void _decodeTerm(DataInput @in, FieldInfo fieldInfo, Lucene41PostingsWriter.IntBlockTermState termState)
 {
     bool fieldHasPositions = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
     bool fieldHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
     bool fieldHasPayloads = fieldInfo.HasPayloads();
     if (termState.DocFreq == 1)
     {
         termState.SingletonDocID = @in.ReadVInt();
     }
     else
     {
         termState.SingletonDocID = -1;
         termState.DocStartFP += @in.ReadVLong();
     }
     if (fieldHasPositions)
     {
         termState.PosStartFP += @in.ReadVLong();
         if (termState.TotalTermFreq > Lucene41PostingsFormat.BLOCK_SIZE)
         {
             termState.LastPosBlockOffset = @in.ReadVLong();
         }
         else
         {
             termState.LastPosBlockOffset = -1;
         }
         if ((fieldHasPayloads || fieldHasOffsets) && termState.TotalTermFreq >= Lucene41PostingsFormat.BLOCK_SIZE)
         {
             termState.PayStartFP += @in.ReadVLong();
         }
     }
     if (termState.DocFreq > Lucene41PostingsFormat.BLOCK_SIZE)
     {
         termState.SkipOffset = @in.ReadVLong();
     }
     else
     {
         termState.SkipOffset = -1;
     }
 }
Пример #7
0
            public DocsEnum Reset(Bits liveDocs, Lucene41PostingsWriter.IntBlockTermState termState, int flags)
            {
                this.LiveDocs = liveDocs;
                // if (DEBUG) {
                //   System.out.println("  FPR.reset: termState=" + termState);
                // }
                DocFreq = termState.DocFreq;
                TotalTermFreq = IndexHasFreq ? termState.TotalTermFreq : DocFreq;
                DocTermStartFP = termState.DocStartFP;
                SkipOffset = termState.SkipOffset;
                SingletonDocID = termState.SingletonDocID;
                if (DocFreq > 1)
                {
                    if (DocIn == null)
                    {
                        // lazy init
                        DocIn = (IndexInput)StartDocIn.Clone();
                    }
                    DocIn.Seek(DocTermStartFP);
                }

                Doc = -1;
                this.NeedsFreq = (flags & DocsEnum.FLAG_FREQS) != 0;
                if (!IndexHasFreq)
                {
                    CollectionsHelper.Fill(FreqBuffer, 1);
                }
                Accum = 0;
                DocUpto = 0;
                NextSkipDoc = Lucene41PostingsFormat.BLOCK_SIZE - 1; // we won't skip if target is found in first block
                DocBufferUpto = Lucene41PostingsFormat.BLOCK_SIZE;
                Skipped = false;
                return this;
            }