Jackie-Jiang commented on a change in pull request #8411: URL: https://github.com/apache/pinot/pull/8411#discussion_r837935497
########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/filter/SortedIndexBasedFilterOperator.java ########## @@ -132,6 +133,92 @@ protected FilterBlock getNextBlock() { } } + @Override + public boolean canOptimizeCount() { + return true; + } + + @Override + public int getNumMatchingDocs() { + int count = 0; + boolean exclusive = _predicateEvaluator.isExclusive(); + if (_predicateEvaluator instanceof SortedDictionaryBasedRangePredicateEvaluator) { + // For RANGE predicate, use start/end document id to construct a new document id range + SortedDictionaryBasedRangePredicateEvaluator rangePredicateEvaluator = + (SortedDictionaryBasedRangePredicateEvaluator) _predicateEvaluator; + int startDocId = _sortedIndexReader.getDocIds(rangePredicateEvaluator.getStartDictId()).getLeft(); + // NOTE: End dictionary id is exclusive in OfflineDictionaryBasedRangePredicateEvaluator. + int endDocId = _sortedIndexReader.getDocIds(rangePredicateEvaluator.getEndDictId() - 1).getRight(); + count = endDocId - startDocId + 1; + } else { + int[] dictIds = + exclusive ? _predicateEvaluator.getNonMatchingDictIds() : _predicateEvaluator.getMatchingDictIds(); + int numDictIds = dictIds.length; + // NOTE: PredicateEvaluator without matching/non-matching dictionary ids should not reach here. + Preconditions.checkState(numDictIds > 0); Review comment: Sorry didn't realize this is just duplicating the existing logic. Checked the usage, and seems regular `REGEXP_LIKE` won't hit this operator. If we run into issues, we can fix it separately -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org