This is an automated email from the ASF dual-hosted git repository.

kharekartik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 15416e5e8a Add option to skip statree index evaluation during query 
(#8737)
15416e5e8a is described below

commit 15416e5e8ada7e8ab546017f048a011862d65ec2
Author: Kartik Khare <[email protected]>
AuthorDate: Tue May 24 11:43:34 2022 +0530

    Add option to skip statree index evaluation during query (#8737)
    
    * Add option to skip statree index evaluation during query
    
    * Make backward compatible
    
    * Refactor: use same key for query option
    
    * removed unused methods
    
    Co-authored-by: Kartik Khare <[email protected]>
---
 .../pinot/core/plan/AggregationGroupByOrderByPlanNode.java    |  2 +-
 .../java/org/apache/pinot/core/plan/AggregationPlanNode.java  |  2 +-
 .../apache/pinot/core/plan/maker/InstancePlanMakerImplV2.java |  4 ++++
 .../apache/pinot/core/query/request/context/QueryContext.java | 10 ++++++++++
 .../java/org/apache/pinot/core/startree/StarTreeUtils.java    | 11 -----------
 .../java/org/apache/pinot/core/util/QueryOptionsUtils.java    |  8 ++++++++
 .../main/java/org/apache/pinot/spi/utils/CommonConstants.java |  1 +
 7 files changed, 25 insertions(+), 13 deletions(-)

diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationGroupByOrderByPlanNode.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationGroupByOrderByPlanNode.java
index 6451b43c83..10fd34f343 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationGroupByOrderByPlanNode.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationGroupByOrderByPlanNode.java
@@ -64,7 +64,7 @@ public class AggregationGroupByOrderByPlanNode implements 
PlanNode {
 
     // Use star-tree to solve the query if possible
     List<StarTreeV2> starTrees = _indexSegment.getStarTrees();
-    if (starTrees != null && !StarTreeUtils.isStarTreeDisabled(_queryContext)) 
{
+    if (starTrees != null && !_queryContext.isSkipStarTree()) {
       AggregationFunctionColumnPair[] aggregationFunctionColumnPairs =
           StarTreeUtils.extractAggregationFunctionPairs(aggregationFunctions);
       if (aggregationFunctionColumnPairs != null) {
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationPlanNode.java 
b/pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationPlanNode.java
index e0ea896609..2f26535d1e 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationPlanNode.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationPlanNode.java
@@ -198,7 +198,7 @@ public class AggregationPlanNode implements PlanNode {
 
     // Use star-tree to solve the query if possible
     List<StarTreeV2> starTrees = _indexSegment.getStarTrees();
-    if (starTrees != null && !StarTreeUtils.isStarTreeDisabled(_queryContext)) 
{
+    if (starTrees != null && !_queryContext.isSkipStarTree()) {
       AggregationFunctionColumnPair[] aggregationFunctionColumnPairs =
           StarTreeUtils.extractAggregationFunctionPairs(aggregationFunctions);
       if (aggregationFunctionColumnPairs != null) {
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/plan/maker/InstancePlanMakerImplV2.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/plan/maker/InstancePlanMakerImplV2.java
index 259a7b78f0..4d9558f6f5 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/plan/maker/InstancePlanMakerImplV2.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/plan/maker/InstancePlanMakerImplV2.java
@@ -186,10 +186,14 @@ public class InstancePlanMakerImplV2 implements PlanMaker 
{
 
   private void applyQueryOptions(QueryContext queryContext) {
     Map<String, String> queryOptions = queryContext.getQueryOptions();
+    Map<String, String> debugOptions = queryContext.getDebugOptions();
 
     // Set skipUpsert
     queryContext.setSkipUpsert(QueryOptionsUtils.isSkipUpsert(queryOptions));
 
+    // Set skipStarTree
+    
queryContext.setSkipStarTree(QueryOptionsUtils.isSkipStarTree(queryOptions, 
debugOptions));
+
     // Set maxExecutionThreads
     int maxExecutionThreads;
     Integer maxExecutionThreadsFromQuery = 
QueryOptionsUtils.getMaxExecutionThreads(queryOptions);
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java
index fe9311e928..cff843d282 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java
@@ -101,6 +101,8 @@ public class QueryContext {
   private boolean _enablePrefetch;
   // Whether to skip upsert for the query
   private boolean _skipUpsert;
+  // Whether to skip star-tree index for the query
+  private boolean _skipStarTree;
   // Maximum number of threads used to execute the query
   private int _maxExecutionThreads = 
InstancePlanMakerImplV2.DEFAULT_MAX_EXECUTION_THREADS;
   // The following properties apply to group-by queries
@@ -314,6 +316,14 @@ public class QueryContext {
     _skipUpsert = skipUpsert;
   }
 
+  public boolean isSkipStarTree() {
+    return _skipStarTree;
+  }
+
+  public void setSkipStarTree(boolean skipStarTree) {
+    _skipStarTree = skipStarTree;
+  }
+
   public int getMaxExecutionThreads() {
     return _maxExecutionThreads;
   }
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/startree/StarTreeUtils.java 
b/pinot-core/src/main/java/org/apache/pinot/core/startree/StarTreeUtils.java
index ada24ad19b..5892e6312b 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/startree/StarTreeUtils.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/startree/StarTreeUtils.java
@@ -35,7 +35,6 @@ import 
org.apache.pinot.common.request.context.predicate.Predicate;
 import org.apache.pinot.core.operator.filter.predicate.PredicateEvaluator;
 import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
 import 
org.apache.pinot.core.query.aggregation.function.AggregationFunctionUtils;
-import org.apache.pinot.core.query.request.context.QueryContext;
 import org.apache.pinot.segment.spi.IndexSegment;
 import org.apache.pinot.segment.spi.datasource.DataSource;
 import org.apache.pinot.segment.spi.index.reader.Dictionary;
@@ -48,16 +47,6 @@ public class StarTreeUtils {
   private StarTreeUtils() {
   }
 
-  public static final String USE_STAR_TREE_KEY = "useStarTree";
-
-  /**
-   * Returns whether star-tree is disabled for the query.
-   */
-  public static boolean isStarTreeDisabled(QueryContext queryContext) {
-    Map<String, String> debugOptions = queryContext.getDebugOptions();
-    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}
diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/util/QueryOptionsUtils.java 
b/pinot-core/src/main/java/org/apache/pinot/core/util/QueryOptionsUtils.java
index 3da7881372..e69da86e3d 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/util/QueryOptionsUtils.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/util/QueryOptionsUtils.java
@@ -47,6 +47,14 @@ public class QueryOptionsUtils {
     return 
Boolean.parseBoolean(queryOptions.get(Request.QueryOptionKey.SKIP_UPSERT));
   }
 
+  // TODO: Debug options has been kept for backward compatibility should be 
deprecated in future releases
+  public static boolean isSkipStarTree(Map<String, String> queryOptions, 
Map<String, String> debugOptions) {
+    boolean disabledWithQueryOption = !Boolean.parseBoolean(
+        queryOptions.getOrDefault(Request.QueryOptionKey.USE_STAR_TREE_KEY, 
"true"));
+    return disabledWithQueryOption || (debugOptions != null
+        && 
!Boolean.parseBoolean(debugOptions.getOrDefault(Request.QueryOptionKey.USE_STAR_TREE_KEY,
 "true")));
+  }
+
   public static Integer getNumReplicaGroupsToQuery(Map<String, String> 
queryOptions) {
     String numReplicaGroupsToQuery = 
queryOptions.get(Request.QueryOptionKey.NUM_REPLICA_GROUPS_TO_QUERY);
     return numReplicaGroupsToQuery != null ? 
Integer.parseInt(numReplicaGroupsToQuery) : null;
diff --git 
a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java 
b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
index d2e6a63f8d..eeb83a6349 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
@@ -248,6 +248,7 @@ public class CommonConstants {
       public static class QueryOptionKey {
         public static final String TIMEOUT_MS = "timeoutMs";
         public static final String SKIP_UPSERT = "skipUpsert";
+        public static final String USE_STAR_TREE_KEY = "useStarTree";
         public static final String MAX_EXECUTION_THREADS = 
"maxExecutionThreads";
         public static final String MIN_SEGMENT_GROUP_TRIM_SIZE = 
"minSegmentGroupTrimSize";
         public static final String MIN_SERVER_GROUP_TRIM_SIZE = 
"minServerGroupTrimSize";


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to