jpountz commented on a change in pull request #658:
URL: https://github.com/apache/lucene/pull/658#discussion_r801605478



##########
File path: lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
##########
@@ -369,6 +369,54 @@ public Scorer scorer(LeafReaderContext context) throws 
IOException {
         return scorerSupplier.get(Long.MAX_VALUE);
       }
 
+      @Override
+      public int count(LeafReaderContext context) throws IOException {
+        LeafReader reader = context.reader();
+
+        PointValues values = reader.getPointValues(field);
+        if (values == null) {
+          // No docs in this segment indexed any points or this field did not 
contain any points
+          return 0;
+        }
+
+        if (values.getNumIndexDimensions() != numDims) {
+          throw new IllegalArgumentException(
+              "field=\""
+                  + field
+                  + "\" was indexed with numIndexDimensions="
+                  + values.getNumIndexDimensions()
+                  + " but this query has numDims="
+                  + numDims);
+        }
+        if (bytesPerDim != values.getBytesPerDimension()) {
+          throw new IllegalArgumentException(
+              "field=\""
+                  + field
+                  + "\" was indexed with bytesPerDim="
+                  + values.getBytesPerDimension()
+                  + " but this query has bytesPerDim="
+                  + bytesPerDim);
+        }
+
+        if (reader.hasDeletions() == false
+            && numDims == 1
+            && values.getDocCount() == reader.maxDoc()

Review comment:
       I don't think we need this check, do we?

##########
File path: lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
##########
@@ -369,6 +369,54 @@ public Scorer scorer(LeafReaderContext context) throws 
IOException {
         return scorerSupplier.get(Long.MAX_VALUE);
       }
 
+      @Override
+      public int count(LeafReaderContext context) throws IOException {
+        LeafReader reader = context.reader();
+
+        PointValues values = reader.getPointValues(field);
+        if (values == null) {
+          // No docs in this segment indexed any points or this field did not 
contain any points
+          return 0;
+        }
+
+        if (values.getNumIndexDimensions() != numDims) {
+          throw new IllegalArgumentException(
+              "field=\""
+                  + field
+                  + "\" was indexed with numIndexDimensions="
+                  + values.getNumIndexDimensions()
+                  + " but this query has numDims="
+                  + numDims);
+        }
+        if (bytesPerDim != values.getBytesPerDimension()) {
+          throw new IllegalArgumentException(
+              "field=\""
+                  + field
+                  + "\" was indexed with bytesPerDim="
+                  + values.getBytesPerDimension()
+                  + " but this query has bytesPerDim="
+                  + bytesPerDim);
+        }

Review comment:
       Maybe extract this logic to a function to share it across the 
`scorerSupplier` and `count` methods?




-- 
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