public FSTTermsReader(SegmentReadState state, PostingsReaderBase postingsReader) throws IOException {final String termsFileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTTermsWriter.TERMS_EXTENSION);this.postingsReader = postingsReader;final IndexInput in = state.directory.openInput(termsFileName, state.context);boolean success = false;try {CodecUtil.checkIndexHeader(in, FSTTermsWriter.TERMS_CODEC_NAME,FSTTermsWriter.TERMS_VERSION_START,FSTTermsWriter.TERMS_VERSION_CURRENT,state.segmentInfo.getId(), state.segmentSuffix);CodecUtil.checksumEntireFile(in);this.postingsReader.init(in, state);seekDir(in);final FieldInfos fieldInfos = state.fieldInfos;final int numFields = in.readVInt();for (int i = 0; i < numFields; i++) {int fieldNumber = in.readVInt();FieldInfo fieldInfo = fieldInfos.fieldInfo(fieldNumber);long numTerms = in.readVLong();long sumTotalTermFreq = in.readVLong();long sumDocFreq = fieldInfo.getIndexOptions() == IndexOptions.DOCS ? sumTotalTermFreq : in.readVLong();int docCount = in.readVInt();TermsReader current = new TermsReader(fieldInfo, in, numTerms, sumTotalTermFreq, sumDocFreq, docCount);TermsReader previous = fields.put(fieldInfo.name, current);checkFieldSummary(state.segmentInfo, in, current, previous);}success = true;} finally {if (success) {IOUtils.close(in);} else {IOUtils.closeWhileHandlingException(in);}}}

public FSTTermsReader(SegmentReadState state, PostingsReaderBase postingsReader){string termsFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, FSTTermsWriter.TERMS_EXTENSION);this.postingsReader = postingsReader;IndexInput @in = state.Directory.OpenInput(termsFileName, state.Context);bool success = false;try{version = ReadHeader(@in);if (version >= FSTTermsWriter.TERMS_VERSION_CHECKSUM){CodecUtil.ChecksumEntireFile(@in);}this.postingsReader.Init(@in);SeekDir(@in);FieldInfos fieldInfos = state.FieldInfos;int numFields = @in.ReadVInt32();for (int i = 0; i < numFields; i++){int fieldNumber = @in.ReadVInt32();FieldInfo fieldInfo = fieldInfos.FieldInfo(fieldNumber);long numTerms = @in.ReadVInt64();long sumTotalTermFreq = fieldInfo.IndexOptions == IndexOptions.DOCS_ONLY ? -1 : @in.ReadVInt64();long sumDocFreq = @in.ReadVInt64();int docCount = @in.ReadVInt32();int longsSize = @in.ReadVInt32();TermsReader current = new TermsReader(this, fieldInfo, @in, numTerms, sumTotalTermFreq, sumDocFreq, docCount, longsSize);TermsReader previous;fields.TryGetValue(fieldInfo.Name, out previous);fields[fieldInfo.Name] = current;CheckFieldSummary(state.SegmentInfo, @in, current, previous);}success = true;}finally{if (success){IOUtils.Dispose(@in);}else{IOUtils.DisposeWhileHandlingException(@in);}}}
