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/10/27 20:40:12 UTC

[GitHub] [pinot] npawar commented on a diff in pull request #9668: add FetchPlanner interface to decide what column index to prefetch

npawar commented on code in PR #9668:
URL: https://github.com/apache/pinot/pull/9668#discussion_r1007198951


##########
pinot-core/src/main/java/org/apache/pinot/core/query/prefetch/FetchPlannerRegistry.java:
##########
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.prefetch;
+
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class FetchPlannerRegistry {
+  private static final AtomicReference<FetchPlanner> REGISTRATION = new AtomicReference<>(null);
+
+  private FetchPlannerRegistry() {
+  }
+
+  private static final class Holder {
+    public static final FetchPlanner PLANNER =
+        Optional.ofNullable(REGISTRATION.get()).orElseGet(DefaultFetchPlanner::new);
+  }
+
+  public static boolean registerPlanner(FetchPlanner planner) {

Review Comment:
   looks like if there was already a non-null planner registered, we won't set the param. Can we add some javadocs for this?



##########
pinot-core/src/main/java/org/apache/pinot/core/query/prefetch/FetchPlanner.java:
##########
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.query.prefetch;
+
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.request.context.predicate.Predicate;
+import org.apache.pinot.core.query.request.context.QueryContext;
+import org.apache.pinot.segment.spi.FetchContext;
+import org.apache.pinot.segment.spi.IndexSegment;
+
+
+/**
+ * FetchPlanner decides what data to prefetch for the given query to reduce the time waiting for data, which might be
+ * read from some slow storage backend, to reduce the query latency. Although the plan methods take in an indexSegment
+ * object, it should mainly access the segment metadata like what types of index it has, as the index data may not be
+ * available, but leaving this to the implementations to check and handle per their own need.
+ * TODO: this interface and the dependent classes like QueryContext should be moved to query-spi pkg, yet to be added.
+ */
+public interface FetchPlanner {
+  /**
+   * Plan what index data to prefetch to help prune the segment before processing it. For example, one can fetch bloom
+   * filter to prune the segment based on the column values in query predicates like IN or EQ.
+   *
+   * @param indexSegment     segment to be pruned.
+   * @param queryContext     context extracted from the query.
+   * @param requestedColumns columns requested for pruning, with predicate type they are from.
+   * @return context to guide data prefetching.
+   */
+  @Nullable
+  FetchContext planFetchForPruning(IndexSegment indexSegment, QueryContext queryContext,
+      @Nullable Map<Predicate.Type, Set<String>> requestedColumns);
+
+  /**
+   * Plan what index data to prefetch to process it. For example, one can fetch all types of index for columns tracked
+   * in QueryContext.
+   *
+   * @param indexSegment segment to be processed.
+   * @param queryContext context extracted from the query.
+   * @return context to guide data prefetching.
+   */
+  FetchContext planFetchForProcessing(IndexSegment indexSegment, QueryContext queryContext);

Review Comment:
   from perspective of interface, should this method also have the predicate to columns map, even though it's unused in Default impl? Or alternatively, should the above method not include it, and let impl deduce it?



-- 
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