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


##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/AggregateOperator.java:
##########
@@ -325,57 +291,126 @@ private ExpressionContext 
convertRexExpressionToExpressionContext(int aggIdx, in
     return exprContext;
   }
 
-  // TODO: If the previous block is not mailbox received, this method is not 
efficient.  Then getDataBlock() will
-  //  convert the unserialized format to serialized format of BaseDataBlock. 
Then it will convert it back to column
-  //  value primitive type.
-  static Map<ExpressionContext, BlockValSet> 
getBlockValSetMap(AggregationFunction aggFunction, TransferableBlock block,
-      DataSchema inputDataSchema, Map<String, Integer> colNameToIndexMap, int 
filterArgIdx) {
+  private int[] getGroupKeyIds(List<RexExpression> groupSet) {
+    int numKeys = groupSet.size();
+    int[] groupKeyIds = new int[numKeys];
+    for (int i = 0; i < numKeys; i++) {
+      RexExpression rexExp = groupSet.get(i);
+      Preconditions.checkState(rexExp.getKind() == SqlKind.INPUT_REF, "Group 
key must be an input reference, got: %s",
+          rexExp.getKind());
+      groupKeyIds[i] = ((RexExpression.InputRef) rexExp).getIndex();
+    }
+    return groupKeyIds;
+  }
+
+  static RoaringBitmap getMatchedBitmap(TransferableBlock block, int 
filterArgId) {
+    Preconditions.checkArgument(filterArgId >= 0, "Got negative filter 
argument id: %s", filterArgId);
+    RoaringBitmap matchedBitmap = new RoaringBitmap();
+    if (block.isContainerConstructed()) {
+      List<Object[]> rows = block.getContainer();
+      int numRows = rows.size();
+      for (int rowId = 0; rowId < numRows; rowId++) {
+        if ((int) rows.get(rowId)[filterArgId] == 1) {
+          matchedBitmap.add(rowId);
+        }
+      }
+    } else {
+      DataBlock dataBlock = block.getDataBlock();
+      int numRows = dataBlock.getNumberOfRows();
+      for (int rowId = 0; rowId < numRows; rowId++) {
+        if (dataBlock.getInt(rowId, filterArgId) == 1) {
+          matchedBitmap.add(rowId);
+        }
+      }
+    }
+    return matchedBitmap;
+  }
+
+  static Map<ExpressionContext, BlockValSet> 
getBlockValSetMap(AggregationFunction<?, ?> aggFunction,
+      TransferableBlock block, Map<String, Integer> colNameToIndexMap) {
     List<ExpressionContext> expressions = aggFunction.getInputExpressions();
     int numExpressions = expressions.size();
     if (numExpressions == 0) {
       return Collections.emptyMap();
     }
-
     Map<ExpressionContext, BlockValSet> blockValSetMap = new HashMap<>();
-    for (ExpressionContext expression : expressions) {
-      if (expression.getType().equals(ExpressionContext.Type.IDENTIFIER) && 
!"__PLACEHOLDER__".equals(

Review Comment:
   i was originally intended to get rid of the `__PLACEHOLDER__`. let's factor 
this into a util or leave a TODO so that it's easier to replace in the future 
(i see 4 `__PLACEHOLDER__` usage in the new impl)



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