dario-liberman commented on code in PR #18760:
URL: https://github.com/apache/pinot/pull/18760#discussion_r3465875212
##########
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();
+ for (int k = 1; k < correlationIds.length; k++) {
+ _lookupKey.add(correlationIds[k]);
+ }
+
+ boolean[] steps = _secondaryKeySteps.get(_lookupKey);
+ if (steps == null) {
+ steps = new boolean[_numSteps];
+ _secondaryKeySteps.put(new IntArrayList(_lookupKey), steps);
Review Comment:
Why do we need to create a clone of lookupKey here? Are we mutating it
somewhere?
--
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]