richardstartin commented on code in PR #10043: URL: https://github.com/apache/pinot/pull/10043#discussion_r1063271581
########## pinot-core/src/main/java/org/apache/pinot/core/operator/filter/RangeIndexBasedFilterOperator.java: ########## @@ -131,27 +139,75 @@ public String toExplainString() { } interface RangeEvaluator { + + Set<FieldSpec.DataType> SUPPORTED_RAW_DATA_TYPES = EnumSet.of(FieldSpec.DataType.INT, + FieldSpec.DataType.LONG, FieldSpec.DataType.FLOAT, FieldSpec.DataType.DOUBLE); + + static boolean canEvaluate(PredicateEvaluator predicateEvaluator, DataSource dataSource) { + if (dataSource.getRangeIndex() != null) { + boolean datatypeSupported = dataSource.getRangeIndex().isExact() + && (predicateEvaluator.isDictionaryBased() + || SUPPORTED_RAW_DATA_TYPES.contains(predicateEvaluator.getDataType())); + switch (predicateEvaluator.getPredicateType()) { + case EQ: + return datatypeSupported && dataSource.getRangeIndex().isExact() + && predicateEvaluator instanceof EqualsPredicateEvaluatorFactory.EqualsPredicateEvaluator; + case RANGE: + return datatypeSupported && (predicateEvaluator instanceof SortedDictionaryBasedRangePredicateEvaluator + || predicateEvaluator instanceof IntRawValueBasedRangePredicateEvaluator + || predicateEvaluator instanceof LongRawValueBasedRangePredicateEvaluator + || predicateEvaluator instanceof FloatRawValueBasedRangePredicateEvaluator + || predicateEvaluator instanceof DoubleRawValueBasedRangePredicateEvaluator); + default: + } + } + return false; + } + static RangeEvaluator of(RangeIndexReader<ImmutableRoaringBitmap> rangeIndexReader, PredicateEvaluator predicateEvaluator) { - if (predicateEvaluator instanceof SortedDictionaryBasedRangePredicateEvaluator) { - return new IntRangeEvaluator(rangeIndexReader, - (SortedDictionaryBasedRangePredicateEvaluator) predicateEvaluator); + if (predicateEvaluator.isDictionaryBased()) { + if (predicateEvaluator instanceof EqualsPredicateEvaluatorFactory.EqualsPredicateEvaluator) { + return new IntPointEvaluator(rangeIndexReader, + (EqualsPredicateEvaluatorFactory.EqualsPredicateEvaluator) predicateEvaluator); Review Comment: I added the interface so that the operator knows less about the predicate evaluators to reduce coupling - I think this approach is better and could be retrofitted onto the range predicate evaluators. If it's a dealbreaker, I'll change it, but I think this is better. -- 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