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



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/reduce/GroupByDataTableReducer.java
##########
@@ -208,50 +232,42 @@ private DataSchema 
getPrePostAggregationDataSchema(DataSchema dataSchema) {
   }
 
   private IndexedTable getIndexedTable(DataSchema dataSchema, 
Collection<DataTable> dataTables) {
-    int indexedTableCapacity = GroupByUtils.getTableCapacity(_queryContext);
-    IndexedTable indexedTable = new ConcurrentIndexedTable(dataSchema, 
_queryContext, indexedTableCapacity);
-
+    int capacity = GroupByUtils.getTableCapacity(_queryContext);
+    IndexedTable indexedTable = new SimpleIndexedTable(dataSchema, 
_queryContext, capacity);
+    ColumnDataType[] columnDataTypes = dataSchema.getColumnDataTypes();
     for (DataTable dataTable : dataTables) {
-      BiFunction[] functions = new BiFunction[_numColumns];
-      for (int i = 0; i < _numColumns; i++) {
-        ColumnDataType columnDataType = dataSchema.getColumnDataType(i);
-        BiFunction<Integer, Integer, Object> function;
-        switch (columnDataType) {
-          case INT:
-            function = dataTable::getInt;
-            break;
-          case LONG:
-            function = dataTable::getLong;
-            break;
-          case FLOAT:
-            function = dataTable::getFloat;
-            break;
-          case DOUBLE:
-            function = dataTable::getDouble;
-            break;
-          case STRING:
-            function = dataTable::getString;
-            break;
-          case BYTES:
-            function = dataTable::getBytes;
-            break;
-          case OBJECT:
-            function = dataTable::getObject;
-            break;
-          // Add other aggregation intermediate result / group-by column type 
supports here
-          default:
-            throw new IllegalStateException();
-        }
-        functions[i] = function;
-      }
-
-      for (int row = 0; row < dataTable.getNumberOfRows(); row++) {
-        Object[] columns = new Object[_numColumns];
-        for (int col = 0; col < _numColumns; col++) {
-          columns[col] = functions[col].apply(row, col);
+      int numRows = dataTable.getNumberOfRows();
+      for (int rowId = 0; rowId < numRows; rowId++) {
+        Object[] values = new Object[_numColumns];
+        for (int colId = 0; colId < _numColumns; colId++) {
+          switch (columnDataTypes[colId]) {

Review comment:
       NOTE: Change this to per-value switch based because we have found that 
this way has better performance (similar change in #4788 for performance 
improvement)




----------------------------------------------------------------
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:
us...@infra.apache.org



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

Reply via email to