xiangfu0 commented on code in PR #18648:
URL: https://github.com/apache/pinot/pull/18648#discussion_r3343772659


##########
pinot-common/src/main/java/org/apache/pinot/common/response/broker/BrokerResponseNativeV2.java:
##########
@@ -163,6 +167,34 @@ public void mergeNumGroupsWarningLimitReached(boolean 
numGroupsWarningLimitReach
     _brokerStats.merge(StatKey.NUM_GROUPS_WARNING_LIMIT_REACHED, 
numGroupsWarningLimitReached);
   }
 
+  @JsonInclude(JsonInclude.Include.NON_EMPTY)
+  public List<String> getEarlyTerminationReasons() {
+    String earlyTerminationReasons = 
_brokerStats.getString(StatKey.EARLY_TERMINATION_REASONS);
+    LinkedHashSet<String> reasons = new LinkedHashSet<>();
+    addEarlyTerminationReasons(earlyTerminationReasons, reasons);
+    return List.copyOf(reasons);
+  }
+
+  public static String mergeEarlyTerminationReasons(@Nullable String 
earlyTerminationReasons1,
+      @Nullable String earlyTerminationReasons2) {
+    LinkedHashSet<String> mergedReasons = new LinkedHashSet<>();
+    addEarlyTerminationReasons(earlyTerminationReasons1, mergedReasons);
+    addEarlyTerminationReasons(earlyTerminationReasons2, mergedReasons);
+    return mergedReasons.isEmpty() ? null : 
String.join(EARLY_TERMINATION_REASON_SEPARATOR, mergedReasons);
+  }
+
+  private static void addEarlyTerminationReasons(@Nullable String 
earlyTerminationReasons,
+      LinkedHashSet<String> mergedReasons) {
+    if (earlyTerminationReasons == null || earlyTerminationReasons.isEmpty()) {
+      return;
+    }
+    for (String earlyTerminationReason : 
earlyTerminationReasons.split(EARLY_TERMINATION_REASON_SEPARATOR)) {

Review Comment:
   Addressed by switching early termination reasons to 
`StatMap.Type.STRING_SET`. The broker response now reads the ordered set 
directly, so the `String.split(...)` allocation path is gone.



##########
pinot-common/src/main/java/org/apache/pinot/common/response/broker/BrokerResponseNativeV2.java:
##########
@@ -54,6 +55,8 @@
     "pools", "rlsFiltersApplied", "groupsTrimmed"
 })
 public class BrokerResponseNativeV2 implements BrokerResponse {
+  private static final String EARLY_TERMINATION_REASON_SEPARATOR = ",";

Review Comment:
   Done. Added `StatMap.Type.STRING_SET` and changed both 
`LeafOperator.StatKey.EARLY_TERMINATION_REASONS` and 
`BrokerResponseNativeV2.StatKey.EARLY_TERMINATION_REASONS` to use it. This 
removes delimiter selection and parser/join handling entirely.



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