public override FieldsProducer FieldsProducer(SegmentReadState state)
 {
     PostingsReaderBase docsReader = null;
     PostingsReaderBase pulsingReaderInner = null;
     PostingsReaderBase pulsingReader = null;
     bool success = false;
     try
     {
         docsReader = new Lucene41PostingsReader(state.Directory, state.FieldInfos, state.SegmentInfo, state.Context, state.SegmentSuffix);
         pulsingReaderInner = new PulsingPostingsReader(state, docsReader);
         pulsingReader = new PulsingPostingsReader(state, pulsingReaderInner);
         FieldsProducer ret = new BlockTreeTermsReader(
                                                       state.Directory, state.FieldInfos, state.SegmentInfo,
                                                       pulsingReader,
                                                       state.Context,
                                                       state.SegmentSuffix,
                                                       state.TermsIndexDivisor);
         success = true;
         return ret;
     }
     finally
     {
         if (!success)
         {
             IOUtils.CloseWhileHandlingException(docsReader, pulsingReaderInner, pulsingReader);
         }
     }
 }
        public override FieldsProducer FieldsProducer(SegmentReadState state)
        {
            PostingsReaderBase postings = new Lucene41PostingsReader(state.Directory, state.FieldInfos, state.SegmentInfo, state.Context, state.SegmentSuffix);
            TermsIndexReaderBase indexReader;

            bool success = false;
            try
            {
                indexReader = new FixedGapTermsIndexReader(state.Directory,
                                                           state.FieldInfos,
                                                           state.SegmentInfo.Name,
                                                           state.TermsIndexDivisor,
                                                           BytesRef.UTF8SortedAsUnicodeComparer,
                                                           state.SegmentSuffix, state.Context);
                success = true;
            }
            finally
            {
                if (!success)
                {
                    postings.Dispose();
                }
            }

            success = false;
            try
            {
                FieldsProducer ret = new BlockTermsReader(indexReader,
                                                          state.Directory,
                                                          state.FieldInfos,
                                                          state.SegmentInfo,
                                                          postings,
                                                          state.Context,
                                                          state.SegmentSuffix);
                success = true;
                return ret;
            }
            finally
            {
                if (!success)
                {
                    try
                    {
                        postings.Dispose();
                    }
                    finally
                    {
                        indexReader.Dispose();
                    }
                }
            }
        }
 public BlockDocsEnum(Lucene41PostingsReader outerInstance, FieldInfo fieldInfo)
 {
     this.OuterInstance = outerInstance;
     this.StartDocIn = outerInstance.DocIn;
     this.DocIn = null;
     IndexHasFreq = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS;
     IndexHasPos = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
     IndexHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
     IndexHasPayloads = fieldInfo.HasPayloads();
     Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
 }
            public EverythingEnum(Lucene41PostingsReader outerInstance, FieldInfo fieldInfo)
            {
                this.OuterInstance = outerInstance;
                this.StartDocIn = outerInstance.DocIn;
                this.DocIn = null;
                this.PosIn = (IndexInput)outerInstance.PosIn.Clone();
                this.PayIn = (IndexInput)outerInstance.PayIn.Clone();
                Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
                IndexHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
                if (IndexHasOffsets)
                {
                    OffsetStartDeltaBuffer = new int[ForUtil.MAX_DATA_SIZE];
                    OffsetLengthBuffer = new int[ForUtil.MAX_DATA_SIZE];
                }
                else
                {
                    OffsetStartDeltaBuffer = null;
                    OffsetLengthBuffer = null;
                    StartOffset_Renamed = -1;
                    EndOffset_Renamed = -1;
                }

                IndexHasPayloads = fieldInfo.HasPayloads();
                if (IndexHasPayloads)
                {
                    PayloadLengthBuffer = new int[ForUtil.MAX_DATA_SIZE];
                    PayloadBytes = new byte[128];
                    Payload_Renamed = new BytesRef();
                }
                else
                {
                    PayloadLengthBuffer = null;
                    PayloadBytes = null;
                    Payload_Renamed = null;
                }
            }