atris commented on a change in pull request #7184:
URL: https://github.com/apache/pinot/pull/7184#discussion_r675917894
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/startree/StarTreeUtils.java
##########
@@ -179,4 +184,96 @@ public static boolean isFitForStarTree(StarTreeV2Metadata
starTreeV2Metadata,
// Check predicate columns
return starTreeDimensions.containsAll(predicateColumns);
}
+
+ /**
+ * Evaluates a given filter to ascertain if the OR clause is valid for
StarTree processing.
+ *
+ * StarTree supports OR predicates on a single dimension only (d1 < 10 OR d1
> 50).
+ *
+ * @return Pair of the result and the single literal on which the predicate
is based. If the
+ * predicate is not valid for execution on StarTree, literal value will be
null
+ */
+ private static Pair<Boolean, String>
isOrClauseValidForStarTree(FilterContext filterContext) {
+ assert filterContext != null;
+
+ Set<String> seenLiterals = new HashSet<>();
+
+ if (!isOrClauseValidForStarTreeInternal(filterContext, seenLiterals)) {
+ return Pair.of(false, null);
+ }
+
+ boolean result = seenLiterals.size() == 1;
+
+ return Pair.of(result, result ? seenLiterals.iterator().next() : null);
+ }
+
+ /** Internal processor for the above evaluator */
+ private static boolean isOrClauseValidForStarTreeInternal(FilterContext
filterContext, Set<String> seenLiterals) {
+ assert filterContext != null;
+
+ if (filterContext.getType() == FilterContext.Type.OR) {
+ List<FilterContext> childFilterContexts = filterContext.getChildren();
+
+ for (FilterContext childFilterContext : childFilterContexts) {
+ isOrClauseValidForStarTreeInternal(childFilterContext, seenLiterals);
+ }
Review comment:
We return true right after this if block -- should that suffice?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]