tarun11Mavani commented on code in PR #18760:
URL: https://github.com/apache/pinot/pull/18760#discussion_r3479545683


##########
pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/function/funnel/SortedAggregationResult.java:
##########
@@ -50,7 +78,50 @@ public void add(int step, int correlationId) {
     _correlatedSteps[step] = true;
   }
 
+  /**
+   * Multi-key add. Data must be sorted by correlationIds[0] (primary key).
+   * Secondary keys are tracked via HashMap within each primary-key group.
+   *
+   * <p>Within a primary-key group, rows for the same (primary, secondary) 
combination may appear
+   * non-contiguously (e.g. interleaved with other secondary keys). This is 
handled correctly
+   * because the HashMap accumulates all step observations per secondary key 
regardless of row order.
+   */
+  public void addMultiKey(int step, int[] correlationIds) {
+    int primaryId = correlationIds[0];
+    if (primaryId != _lastPrimaryId) {
+      flushMultiKeyGroup();
+      _lastPrimaryId = primaryId;
+      _secondaryKeySteps.clear();
+    }
+
+    _lookupKey.clear();

Review Comment:
   Done — replaced the `HashMap<IntArrayList, boolean[]>` with pre-allocated 
flat arrays (`int[][]` + `boolean[][]`, initial capacity 8) and linear scan.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to