LUCENE-10656: It is unnecessary that using `limit` to check boundary (#1027)

This commit is contained in:
Lu Xugang 2022-07-20 10:00:06 +08:00 committed by GitHub
parent 28ce8abb51
commit 39e7597f6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 13 deletions

View File

@ -253,9 +253,6 @@ class SortedNumericDocValuesWriter extends DocValuesWriter<SortedNumericDocValue
@Override @Override
public long nextValue() { public long nextValue() {
if (valueUpto == valueCount) {
throw new IllegalStateException();
}
valueUpto++; valueUpto++;
return valuesIter.next(); return valuesIter.next();
} }
@ -272,7 +269,6 @@ class SortedNumericDocValuesWriter extends DocValuesWriter<SortedNumericDocValue
private int docID = -1; private int docID = -1;
private long upto; private long upto;
private int numValues = -1; private int numValues = -1;
private long limit;
SortingSortedNumericDocValues(SortedNumericDocValues in, LongValues values) { SortingSortedNumericDocValues(SortedNumericDocValues in, LongValues values) {
this.in = in; this.in = in;
@ -294,7 +290,6 @@ class SortedNumericDocValuesWriter extends DocValuesWriter<SortedNumericDocValue
} while (values.offsets[docID] <= 0); } while (values.offsets[docID] <= 0);
upto = values.offsets[docID]; upto = values.offsets[docID];
numValues = Math.toIntExact(values.values.get(upto - 1)); numValues = Math.toIntExact(values.values.get(upto - 1));
limit = upto + numValues;
return docID; return docID;
} }
@ -309,21 +304,14 @@ class SortedNumericDocValuesWriter extends DocValuesWriter<SortedNumericDocValue
upto = values.offsets[docID]; upto = values.offsets[docID];
if (values.offsets[docID] > 0) { if (values.offsets[docID] > 0) {
numValues = Math.toIntExact(values.values.get(upto - 1)); numValues = Math.toIntExact(values.values.get(upto - 1));
limit = upto + numValues;
return true; return true;
} else {
limit = upto;
} }
return false; return false;
} }
@Override @Override
public long nextValue() { public long nextValue() {
if (upto == limit) { return values.values.get(upto++);
throw new AssertionError();
} else {
return values.values.get(upto++);
}
} }
@Override @Override