//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: DirectDocValuesProducer(index.SegmentReadState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws java.io.IOException
        internal DirectDocValuesProducer(SegmentReadState state, string dataCodec, string dataExtension, string metaCodec, string metaExtension)
        {
            maxDoc = state.segmentInfo.DocCount;
            string metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
            // read in the entries from the metadata file.
            ChecksumIndexInput @in = state.directory.openChecksumInput(metaName, state.context);

            ramBytesUsed_Renamed = new AtomicLong(RamUsageEstimator.shallowSizeOfInstance(this.GetType()));
            bool success = false;

            try
            {
                version = CodecUtil.checkHeader(@in, metaCodec, VERSION_START, VERSION_CURRENT);
                readFields(@in);

                if (version >= VERSION_CHECKSUM)
                {
                    CodecUtil.checkFooter(@in);
                }
                else
                {
                    CodecUtil.checkEOF(@in);
                }
                success = true;
            }
            finally
            {
                if (success)
                {
                    IOUtils.close(@in);
                }
                else
                {
                    IOUtils.closeWhileHandlingException(@in);
                }
            }

            success = false;
            try
            {
                string dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
                data = state.directory.openInput(dataName, state.context);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int version2 = codecs.CodecUtil.checkHeader(data, dataCodec, VERSION_START, VERSION_CURRENT);
                int version2 = CodecUtil.checkHeader(data, dataCodec, VERSION_START, VERSION_CURRENT);
                if (version != version2)
                {
                    throw new CorruptIndexException("Format versions mismatch");
                }

                success = true;
            }
            finally
            {
                if (!success)
                {
                    IOUtils.closeWhileHandlingException(this.data);
                }
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public codecs.FieldsProducer fieldsProducer(index.SegmentReadState state) throws java.io.IOException
        public override FieldsProducer fieldsProducer(SegmentReadState state)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String fileName = index.IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
            string fileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final store.ChecksumIndexInput in = state.directory.openChecksumInput(fileName, store.IOContext.READONCE);
            ChecksumIndexInput @in = state.directory.openChecksumInput(fileName, IOContext.READONCE);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.SortedMap<String,TermsReader> fields = new java.util.TreeMap<>();
            SortedMap <string, TermsReader> fields = new SortedDictionary <string, TermsReader>();

            try
            {
                CodecUtil.checkHeader(@in, CODEC_NAME, VERSION_START, VERSION_CURRENT);
                while (true)
                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int termCount = in.readVInt();
                    int termCount = @in.readVInt();
                    if (termCount == 0)
                    {
                        break;
                    }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final TermsReader termsReader = new TermsReader(state.fieldInfos, in, termCount);
                    TermsReader termsReader = new TermsReader(state.fieldInfos, @in, termCount);
                    // System.out.println("load field=" + termsReader.field.name);
                    fields.put(termsReader.field.name, termsReader);
                }
                CodecUtil.checkFooter(@in);
            }
            finally
            {
                @in.close();
            }

            return(new FieldsProducerAnonymousInnerClassHelper(this, fields));
        }