You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/06/19 07:19:02 UTC

[GitHub] [pinot] kishoreg commented on a diff in pull request #6109: Enhance star-tree to skip matching-all predicate on non-star-tree dimension

kishoreg commented on code in PR #6109:
URL: https://github.com/apache/pinot/pull/6109#discussion_r901059806


##########
pinot-core/src/main/java/org/apache/pinot/core/startree/StarTreeUtils.java:
##########
@@ -54,27 +67,114 @@ public static boolean isStarTreeDisabled(QueryContext queryContext) {
     return debugOptions != null && "false".equalsIgnoreCase(debugOptions.get(USE_STAR_TREE_KEY));
   }
 
+  /**
+   * Extracts the {@link AggregationFunctionColumnPair}s from the given {@link AggregationFunction}s. Returns
+   * {@code null} if any {@link AggregationFunction} cannot be represented as an {@link AggregationFunctionColumnPair}
+   * (e.g. has multiple arguments, argument is not column etc.).
+   */
+  @Nullable
+  public static AggregationFunctionColumnPair[] extractAggregationFunctionPairs(
+      AggregationFunction[] aggregationFunctions) {
+    int numAggregationFunctions = aggregationFunctions.length;
+    AggregationFunctionColumnPair[] aggregationFunctionColumnPairs =
+        new AggregationFunctionColumnPair[numAggregationFunctions];
+    for (int i = 0; i < numAggregationFunctions; i++) {
+      AggregationFunctionColumnPair aggregationFunctionColumnPair =
+          AggregationFunctionUtils.getAggregationFunctionColumnPair(aggregationFunctions[i]);
+      if (aggregationFunctionColumnPair != null) {
+        aggregationFunctionColumnPairs[i] = aggregationFunctionColumnPair;
+      } else {
+        return null;
+      }
+    }
+    return aggregationFunctionColumnPairs;
+  }
+
+  /**
+   * Extracts a map from the column to a list of {@link PredicateEvaluator}s for it. Returns {@code null} if the filter
+   * cannot be solved by the star-tree.
+   */
+  @Nullable
+  public static Map<String, List<PredicateEvaluator>> extractPredicateEvaluatorsMap(IndexSegment indexSegment,
+      @Nullable FilterContext filter) {
+    if (filter == null) {
+      return Collections.emptyMap();
+    }
+
+    Map<String, List<PredicateEvaluator>> predicateEvaluatorsMap = new HashMap<>();
+    Queue<FilterContext> queue = new LinkedList<>();
+    queue.add(filter);
+    FilterContext filterNode;
+    while ((filterNode = queue.poll()) != null) {
+      switch (filterNode.getType()) {
+        case AND:
+          queue.addAll(filterNode.getChildren());
+          break;
+        case OR:
+          // Star-tree does not support OR filter
+          return null;
+        case PREDICATE:
+          Predicate predicate = filterNode.getPredicate();
+          ExpressionContext lhs = predicate.getLhs();
+          if (lhs.getType() != ExpressionContext.Type.IDENTIFIER) {
+            // Star-tree does not support non-identifier expression
+            return null;
+          }
+          String column = lhs.getIdentifier();
+          DataSource dataSource = indexSegment.getDataSource(column);
+          Dictionary dictionary = dataSource.getDictionary();
+          if (dictionary == null) {
+            // Star-tree does not support non-dictionary encoded dimension
+            return null;
+          }
+          switch (predicate.getType()) {

Review Comment:
   its better to have a list of predicates that we support instead of exclusion list. this will future proof us when we add another predicate later and they are not aware of this code



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org