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 2021/12/16 02:02:54 UTC

[GitHub] [pinot] Jackie-Jiang commented on a change in pull request #7911: add full GRPC E2E support

Jackie-Jiang commented on a change in pull request #7911:
URL: https://github.com/apache/pinot/pull/7911#discussion_r770166557



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/ResultReducerFactory.java
##########
@@ -68,11 +67,30 @@ public static DataTableReducer getResultReducer(QueryContext queryContext) {
   }
 
   public static StreamingReducer getStreamingReducer(QueryContext queryContext) {
-    if (!QueryContextUtils.isSelectionQuery(queryContext) || queryContext.getOrderByExpressions() != null) {
-      throw new UnsupportedOperationException("Only selection queries are supported");
+    AggregationFunction[] aggregationFunctions = queryContext.getAggregationFunctions();
+    if (aggregationFunctions == null) {
+      if (queryContext.getOrderByExpressions() != null) {
+        throw new UnsupportedOperationException("Only selection queries are supported");

Review comment:
       Selection order-by is still not supported

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/StreamingAggregationDataTableReducer.java
##########
@@ -0,0 +1,172 @@
+/**
+ * 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.reduce;
+
+import com.google.common.base.Preconditions;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.response.broker.AggregationResult;
+import org.apache.pinot.common.response.broker.BrokerResponseNative;
+import org.apache.pinot.common.response.broker.ResultTable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.common.utils.DataTable;
+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.core.transport.ServerRoutingInstance;
+import org.apache.pinot.core.util.QueryOptionsUtils;
+
+
+/**
+ * Helper class to reduce and set Aggregation results into the BrokerResponseNative
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class StreamingAggregationDataTableReducer implements StreamingReducer {
+  private final QueryContext _queryContext;
+  private final AggregationFunction[] _aggregationFunctions;
+  private final boolean _preserveType;
+  private final int _numAggregationFunctions;
+  private final Object[] _intermediateResults;
+
+  private DataSchema _dataSchema;
+  private DataTableReducerContext _dataTableReducerContext;
+
+  StreamingAggregationDataTableReducer(QueryContext queryContext) {
+    _queryContext = queryContext;
+    _aggregationFunctions = queryContext.getAggregationFunctions();
+    Map<String, String> queryOptions = queryContext.getQueryOptions();
+    _preserveType = QueryOptionsUtils.isPreserveType(queryOptions);
+
+    Preconditions.checkNotNull(_aggregationFunctions);
+    _numAggregationFunctions = _aggregationFunctions.length;
+    _intermediateResults = new Object[_numAggregationFunctions];
+    _dataSchema = null;
+  }
+
+  @Override
+  public void init(DataTableReducerContext dataTableReducerContext) {
+    _dataTableReducerContext = dataTableReducerContext;
+  }
+
+  /**
+   * Reduces data tables and sets aggregations results into
+   * 1. ResultTable if _responseFormatSql is true
+   * 2. AggregationResults by default
+   */
+  @Override
+  public void reduce(ServerRoutingInstance key, DataTable dataTable) {

Review comment:
       (major) We need to make sure all `reduce()` is thread safe. Same for other streaming reducers.

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/reduce/StreamingSelectionOnlyReducer.java
##########
@@ -35,8 +35,8 @@
 import org.slf4j.LoggerFactory;
 
 
-public class SelectionOnlyStreamingReducer implements StreamingReducer {
-  private static final Logger LOGGER = LoggerFactory.getLogger(SelectionOnlyStreamingReducer.class);
+public class StreamingSelectionOnlyReducer implements StreamingReducer {

Review comment:
       (minor) I feel the original class name is easier find. If you change the class name to prevent it from mixing into the non-streaming ones, we can move all the streaming reducers one level down under the `streaming` package




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