walterddr commented on code in PR #9767:
URL: https://github.com/apache/pinot/pull/9767#discussion_r1017357810


##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/AggregateOperatorTest.java:
##########
@@ -18,26 +18,208 @@
  */
 package org.apache.pinot.query.runtime.operator;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 import java.util.Arrays;
 import java.util.List;
 import org.apache.calcite.sql.SqlKind;
+import org.apache.pinot.common.datablock.DataBlock;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.core.common.Operator;
 import org.apache.pinot.core.operator.BaseOperator;
 import org.apache.pinot.query.planner.logical.RexExpression;
 import org.apache.pinot.query.runtime.blocks.TransferableBlock;
+import org.apache.pinot.query.runtime.blocks.TransferableBlockUtils;
 import org.apache.pinot.spi.data.FieldSpec;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
 import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import static org.apache.pinot.common.utils.DataSchema.ColumnDataType.DOUBLE;
+import static org.apache.pinot.common.utils.DataSchema.ColumnDataType.INT;
 
 
 public class AggregateOperatorTest {
 
+  private AutoCloseable _mocks;
+
+  @Mock
+  private Operator<TransferableBlock> _input;

Review Comment:
   using this looks like promising than the mock operator factory if we are 
testing not just the data but also the mock behaviors (e.g. validate called, 
validate called with specific arguments)



##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/AggregateOperator.java:
##########
@@ -53,17 +56,33 @@
  * If the input is single value, the output type will be input type. 
Otherwise, the output type will be double.
  */
 public class AggregateOperator extends BaseOperator<TransferableBlock> {
+
+  interface Merger extends BiFunction<Object, Object, Object> {
+  }
+
   private static final String EXPLAIN_NAME = "AGGREGATE_OPERATOR";
+  private static final Map<String, Merger> MERGERS = ImmutableMap

Review Comment:
   can we put these together with the holder?



##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/AggregateOperator.java:
##########
@@ -228,4 +240,38 @@ private static Key extraRowKey(Object[] row, 
List<RexExpression> groupSet) {
     }
     return new Key(keyElements);
   }
+
+  private static class Holder {

Review Comment:
   this refactoring is great. i was wondering if we can further refactor this. 
into a `Accumulator` class which holds the data but also holds the merge 
methods. not necessarily needed to be in this PR thought=



##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/AggregateOperator.java:
##########
@@ -123,11 +138,14 @@ public String toExplainString() {
   @Override
   protected TransferableBlock getNextBlock() {
     try {
-      if (!_readyToConstruct) {
-        consumeInputBlocks();
+      if (!_readyToConstruct && !consumeInputBlocks()) {

Review Comment:
   👍 



-- 
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-unsubscr...@pinot.apache.org

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