sonatype-lift[bot] commented on a change in pull request #510:
URL: https://github.com/apache/lucene/pull/510#discussion_r761853692



##########
File path: lucene/core/src/java/org/apache/lucene/search/DocIdSetIterator.java
##########
@@ -101,36 +101,57 @@ public static final DocIdSetIterator range(int minDoc, 
int maxDoc) {
     if (minDoc < 0) {
       throw new IllegalArgumentException("minDoc must be >= 0 but got minDoc=" 
+ minDoc);
     }
-    return new DocIdSetIterator() {
-      private int doc = -1;
+    return new RangeDocIdSetIterator(minDoc, maxDoc);
+  }
 
-      @Override
-      public int docID() {
-        return doc;
-      }
+  /**
+   * A {@link DocIdSetIterator} that matches a range documents from minDocID 
(inclusive) to maxDocID
+   * (exclusive).
+   */
+  public static class RangeDocIdSetIterator extends DocIdSetIterator {
+    private final int minDoc;
+    private final int maxDoc;
+    private int doc = -1;
+
+    public RangeDocIdSetIterator(int minDoc, int maxDoc) {
+      this.minDoc = minDoc;
+      this.maxDoc = maxDoc;
+    }
 
-      @Override
-      public int nextDoc() throws IOException {
-        return advance(doc + 1);
-      }
+    @Override
+    public int docID() {
+      return doc;
+    }
 
-      @Override
-      public int advance(int target) throws IOException {
-        if (target < minDoc) {
-          doc = minDoc;
-        } else if (target >= maxDoc) {
-          doc = NO_MORE_DOCS;
-        } else {
-          doc = target;
-        }
-        return doc;
-      }
+    @Override
+    public int nextDoc() throws IOException {
+      return advance(doc + 1);
+    }
 
-      @Override
-      public long cost() {
-        return maxDoc - minDoc;
+    @Override
+    public int advance(int target) throws IOException {
+      if (target < minDoc) {
+        doc = minDoc;
+      } else if (target >= maxDoc) {
+        doc = NO_MORE_DOCS;
+      } else {
+        doc = target;
       }
-    };
+      return doc;
+    }
+
+    public int getMinDoc() {
+      return minDoc;
+    }
+
+    public int getMaxDoc() {
+      return maxDoc;
+    }
+
+    @Override
+    public long cost() {
+      return maxDoc - minDoc;

Review comment:
       *IntLongMath:*  Expression of type int may overflow before being 
assigned to a long [(details)](https://errorprone.info/bugpattern/IntLongMath)
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with 
`help` or `ignore`)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to