You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/02/09 11:40:44 UTC

[GitHub] [lucene] iverase commented on a change in pull request #658: LUCENE-10378 Implement Weight#count for PointRangeQuery

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



##########
File path: lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
##########
@@ -369,6 +376,45 @@ 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 (checkValidPointValues(values) == false) {
+          return 0;
+        }
+
+        if (reader.hasDeletions() == false
+            && numDims == 1
+            && values.getDocCount() == values.size()) {
+          // if all documents have at-most one point
+          final int[] intersectingLeafNodeCount = {0};
+          // create a custom IntersectVisitor that records the number of leafNodes that matched
+          final IntersectVisitor visitor =
+              new IntersectVisitor() {
+                @Override
+                public void visit(int docID) {
+                  intersectingLeafNodeCount[0]++;

Review comment:
       I would really prefer all the count logic is in the method PointValues#pointCount. Let's consider the signature I propose in the issue. Then you just need to do the following:
   ```
   return Math.toIntExact(values.pointCount(this::relate, this::matches));
   ```




-- 
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-unsubscribe@lucene.apache.org

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



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