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 2019/11/07 18:14:10 UTC

[GitHub] [incubator-pinot] kishoreg commented on a change in pull request #4798: Decouple Key from Record

kishoreg commented on a change in pull request #4798: Decouple Key from Record
URL: https://github.com/apache/incubator-pinot/pull/4798#discussion_r343789269
 
 

 ##########
 File path: pinot-core/src/main/java/org/apache/pinot/core/data/table/BaseTable.java
 ##########
 @@ -0,0 +1,94 @@
+/**
+ * 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.data.table;
+
+import java.util.Iterator;
+import java.util.List;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.pinot.common.request.AggregationInfo;
+import org.apache.pinot.common.request.SelectionSort;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunctionUtils;
+
+
+/**
+ * Base abstract implementation of Table
+ */
+public abstract class BaseTable implements Table {
+
+  final AggregationFunction[] _aggregationFunctions;
+  final int _numAggregations;
+  final DataSchema _dataSchema;
+  final int _numColumns;
+
+  // the capacity we need to trim to
+  final int _capacity;
+  // the capacity with added buffer, in order to collect more records than capacity for better precision
+  final int _maxCapacity;
+
+  final boolean _isOrderBy;
+  final TableResizer _tableResizer;
+
+  /**
+   * Initializes the variables and comparators needed for the table
+   */
+  BaseTable(DataSchema dataSchema, List<AggregationInfo> aggregationInfos, List<SelectionSort> orderBy, int capacity) {
+    _dataSchema = dataSchema;
+    _numColumns = dataSchema.size();
+
+    _numAggregations = aggregationInfos.size();
+    _aggregationFunctions = new AggregationFunction[_numAggregations];
+    for (int i = 0; i < _numAggregations; i++) {
+      _aggregationFunctions[i] =
+          AggregationFunctionUtils.getAggregationFunctionContext(aggregationInfos.get(i)).getAggregationFunction();
+    }
+
+    _isOrderBy = CollectionUtils.isNotEmpty(orderBy);
+    if (_isOrderBy) {
+      _tableResizer = new TableResizer(dataSchema, aggregationInfos, orderBy);
+
+      // TODO: tune these numbers
+      // Based on the capacity and maxCapacity, the resizer will smartly choose to evict/retain recors from the PQ
+      if (capacity <= 100_000) { // Capacity is small, make a very large buffer. Make PQ of records to retain, during resize
+        _maxCapacity = 1_000_000;
+      } else { // Capacity is large, make buffer only slightly bigger. Make PQ of records to evict, during resize
+        _maxCapacity = (int) (capacity * 1.2);
 
 Review comment:
   this is kind of unfair :-)  If capacity is 99k, max capacity is 1m but if capacity is 100k max capacity is 102k.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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