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 13:26:53 UTC

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

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


##########
lucene/sandbox/src/java/org/apache/lucene/sandbox/search/IndexSortSortedNumericDocValuesRangeQuery.java:
##########
@@ -212,9 +212,9 @@ public boolean isCacheable(LeafReaderContext ctx) {
       @Override
       public int count(LeafReaderContext context) throws IOException {
         if (context.reader().hasDeletions() == false) {
-          BoundedDocIdSetIterator disi = getDocIdSetIteratorOrNull(context);
-          if (disi != null && disi.delegate == null) {
-            return disi.lastDoc - disi.firstDoc;
+          DocIdSetIterator disi = getDocIdSetIteratorOrNull(context);
+          if (disi != null && disi instanceof BoundedDocIdSetIterator == false) {
+            return Math.toIntExact(disi.cost());

Review Comment:
   I worry that this might be a bit fragile since cost() has no guarantee to be accurate. I wonder if we could make `getDocIdSetIteratorOrNull()` return both a `DocIdSetIterator` and a number of matches (possibly -1 when unknown) to make this less trappy.



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