You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2022/05/24 06:26:27 UTC
[lucene] branch branch_9x updated: LUCENE-10586: Minor cleanup local variables in BlockTreeTermsReader (#918)
This is an automated email from the ASF dual-hosted git repository.
tomoko pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 2cd9eb13262 LUCENE-10586: Minor cleanup local variables in BlockTreeTermsReader (#918)
2cd9eb13262 is described below
commit 2cd9eb13262a0598c6f3c0409103121e72256772
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Tue May 24 15:22:34 2022 +0900
LUCENE-10586: Minor cleanup local variables in BlockTreeTermsReader (#918)
---
.../blocktree/Lucene90BlockTreeTermsReader.java | 38 ++++++++++------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java
index b68ab3eb8f3..2b8827c7023 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/blocktree/Lucene90BlockTreeTermsReader.java
@@ -151,7 +151,6 @@ public final class Lucene90BlockTreeTermsReader extends FieldsProducer {
long indexLength = -1, termsLength = -1;
try (ChecksumIndexInput metaIn = state.directory.openChecksumInput(metaName, state.context)) {
try {
- final IndexInput indexMetaIn, termsMetaIn;
CodecUtil.checkIndexHeader(
metaIn,
TERMS_META_CODEC_NAME,
@@ -159,52 +158,51 @@ public final class Lucene90BlockTreeTermsReader extends FieldsProducer {
version,
state.segmentInfo.getId(),
state.segmentSuffix);
- indexMetaIn = termsMetaIn = metaIn;
postingsReader.init(metaIn, state);
- final int numFields = termsMetaIn.readVInt();
+ final int numFields = metaIn.readVInt();
if (numFields < 0) {
- throw new CorruptIndexException("invalid numFields: " + numFields, termsMetaIn);
+ throw new CorruptIndexException("invalid numFields: " + numFields, metaIn);
}
fieldMap = new HashMap<>((int) (numFields / 0.75f) + 1);
for (int i = 0; i < numFields; ++i) {
- final int field = termsMetaIn.readVInt();
- final long numTerms = termsMetaIn.readVLong();
+ final int field = metaIn.readVInt();
+ final long numTerms = metaIn.readVLong();
if (numTerms <= 0) {
throw new CorruptIndexException(
- "Illegal numTerms for field number: " + field, termsMetaIn);
+ "Illegal numTerms for field number: " + field, metaIn);
}
- final BytesRef rootCode = readBytesRef(termsMetaIn);
+ final BytesRef rootCode = readBytesRef(metaIn);
final FieldInfo fieldInfo = state.fieldInfos.fieldInfo(field);
if (fieldInfo == null) {
- throw new CorruptIndexException("invalid field number: " + field, termsMetaIn);
+ throw new CorruptIndexException("invalid field number: " + field, metaIn);
}
- final long sumTotalTermFreq = termsMetaIn.readVLong();
+ final long sumTotalTermFreq = metaIn.readVLong();
// when frequencies are omitted, sumDocFreq=sumTotalTermFreq and only one value is
// written.
final long sumDocFreq =
fieldInfo.getIndexOptions() == IndexOptions.DOCS
? sumTotalTermFreq
- : termsMetaIn.readVLong();
- final int docCount = termsMetaIn.readVInt();
- BytesRef minTerm = readBytesRef(termsMetaIn);
- BytesRef maxTerm = readBytesRef(termsMetaIn);
+ : metaIn.readVLong();
+ final int docCount = metaIn.readVInt();
+ BytesRef minTerm = readBytesRef(metaIn);
+ BytesRef maxTerm = readBytesRef(metaIn);
if (docCount < 0
|| docCount > state.segmentInfo.maxDoc()) { // #docs with field must be <= #docs
throw new CorruptIndexException(
"invalid docCount: " + docCount + " maxDoc: " + state.segmentInfo.maxDoc(),
- termsMetaIn);
+ metaIn);
}
if (sumDocFreq < docCount) { // #postings must be >= #docs with field
throw new CorruptIndexException(
- "invalid sumDocFreq: " + sumDocFreq + " docCount: " + docCount, termsMetaIn);
+ "invalid sumDocFreq: " + sumDocFreq + " docCount: " + docCount, metaIn);
}
if (sumTotalTermFreq < sumDocFreq) { // #positions must be >= #postings
throw new CorruptIndexException(
"invalid sumTotalTermFreq: " + sumTotalTermFreq + " sumDocFreq: " + sumDocFreq,
- termsMetaIn);
+ metaIn);
}
- final long indexStartFP = indexMetaIn.readVLong();
+ final long indexStartFP = metaIn.readVLong();
FieldReader previous =
fieldMap.put(
fieldInfo.name,
@@ -217,12 +215,12 @@ public final class Lucene90BlockTreeTermsReader extends FieldsProducer {
sumDocFreq,
docCount,
indexStartFP,
- indexMetaIn,
+ metaIn,
indexIn,
minTerm,
maxTerm));
if (previous != null) {
- throw new CorruptIndexException("duplicate field: " + fieldInfo.name, termsMetaIn);
+ throw new CorruptIndexException("duplicate field: " + fieldInfo.name, metaIn);
}
}
indexLength = metaIn.readLong();