gargvishesh commented on code in PR #16846:
URL: https://github.com/apache/druid/pull/16846#discussion_r1705065027


##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -174,11 +181,30 @@ public static CompactionConfigValidationResult 
validateMaxNumTasksForMSQ(Map<Str
                                     
.getInt(ClientMSQContext.CTX_MAX_NUM_TASKS, 
ClientMSQContext.DEFAULT_MAX_NUM_TASKS);
       if (maxNumTasks < 2) {
         return CompactionConfigValidationResult.failure(
-            "MSQ: Context maxNumTasks[%,d] must be at least 2 (1 controller + 
1 worker)",
+            "MSQ: Context 'maxNumTasks'[%,d] must be at least 2 (1 controller 
+ 1 worker)",
             maxNumTasks
         );
       }
     }
     return CompactionConfigValidationResult.success();
   }
+
+  /**
+   * Validate each metric is idempotent, i.e. it defines some 
aggregatorFactory 'A' s.t. 'A = A.combiningFactory()'.
+   */
+  public static CompactionConfigValidationResult 
validateMetricsSpecForMSQ(AggregatorFactory[] metricsSpec)
+  {
+    if (metricsSpec == null) {
+      return CompactionConfigValidationResult.success();
+    }
+    return Arrays.stream(metricsSpec)
+                 .filter(aggregatorFactory ->
+                             
!aggregatorFactory.equals(aggregatorFactory.getCombiningFactory()))
+                 .findFirst()
+                 .map(aggregatorFactory ->
+                          CompactionConfigValidationResult.failure(
+                              "MSQ: Non-idempotent aggregator[%s] not 
supported in 'metricsSpec'.",
+                              aggregatorFactory.getName()
+                          
)).orElse(CompactionConfigValidationResult.success());

Review Comment:
   Updated.



##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -174,11 +181,30 @@ public static CompactionConfigValidationResult 
validateMaxNumTasksForMSQ(Map<Str
                                     
.getInt(ClientMSQContext.CTX_MAX_NUM_TASKS, 
ClientMSQContext.DEFAULT_MAX_NUM_TASKS);
       if (maxNumTasks < 2) {
         return CompactionConfigValidationResult.failure(
-            "MSQ: Context maxNumTasks[%,d] must be at least 2 (1 controller + 
1 worker)",
+            "MSQ: Context 'maxNumTasks'[%,d] must be at least 2 (1 controller 
+ 1 worker)",
             maxNumTasks
         );
       }
     }
     return CompactionConfigValidationResult.success();
   }
+
+  /**
+   * Validate each metric is idempotent, i.e. it defines some 
aggregatorFactory 'A' s.t. 'A = A.combiningFactory()'.
+   */
+  public static CompactionConfigValidationResult 
validateMetricsSpecForMSQ(AggregatorFactory[] metricsSpec)
+  {
+    if (metricsSpec == null) {
+      return CompactionConfigValidationResult.success();
+    }
+    return Arrays.stream(metricsSpec)
+                 .filter(aggregatorFactory ->
+                             
!aggregatorFactory.equals(aggregatorFactory.getCombiningFactory()))

Review Comment:
   Updated.



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