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/12/10 00:46:59 UTC

[GitHub] [lucene] gsmiller commented on a diff in pull request #12003: Some minor code cleanup in IndexSortSortedNumericDocValuesRangeQuery

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