dario-liberman commented on code in PR #18760:
URL: https://github.com/apache/pinot/pull/18760#discussion_r3471187193


##########
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:
   All I am trying to find is a way to avoid allocations. There must be ways to 
reuse fast util maps or perhaps have array lookups for scenarios up to say 5 
entries. Teams mostly use secondary correlation for things like order id, 
mobile session if, device id, etc, but it is very rare to have multiple 
simultaneous trips per user, or multiple sessions or devices per user, and even 
when it happens we usually talk about a small number. I think we need as much 
as possible to optimise for this in the sorted case.



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