You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by lu...@apache.org on 2022/07/20 02:00:10 UTC

[lucene] branch main updated: LUCENE-10656: It is unnecessary that using `limit` to check boundary (#1027)

This is an automated email from the ASF dual-hosted git repository.

luxugang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 39e7597f6e8 LUCENE-10656: It is unnecessary that using `limit` to check boundary (#1027)
39e7597f6e8 is described below

commit 39e7597f6e83e10136323e5a67cbdf45a13c4f2b
Author: Lu Xugang <lu...@apache.org>
AuthorDate: Wed Jul 20 10:00:06 2022 +0800

    LUCENE-10656: It is unnecessary that using `limit` to check boundary (#1027)
---
 .../apache/lucene/index/SortedNumericDocValuesWriter.java  | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

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