gsmiller commented on code in PR #12003:
URL: https://github.com/apache/lucene/pull/12003#discussion_r1044931897


##########
lucene/sandbox/src/java/org/apache/lucene/sandbox/search/IndexSortSortedNumericDocValuesRangeQuery.java:
##########
@@ -692,7 +697,7 @@ public int advance(int target) throws IOException {
 
     @Override
     public long cost() {
-      return lastDoc - firstDoc;
+      return Math.min(delegate.cost(), lastDoc - firstDoc);

Review Comment:
   Good question. So `delegate.cost()` will approximate the number of documents 
that could be provided in total by the delegate (in this case, it's 
`NumericDocValues`). `lastDoc - firstDoc` of course will provide the correct 
number of docs _if_ every doc has a value. In this case, `delegate` tells us 
what docs actually have values, and because we're using this, we know not all 
docs have values, so `lastDoc - firstDoc` _may_ overestimate. If the number of 
docs containing a value are very sparse though, it's possible we'll 
over-estimate by a lot, so providing a ceiling using `delegate.cost()` could be 
useful in certain cases. Hope that makes sense?



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