cloud-fan commented on code in PR #57355:
URL: https://github.com/apache/spark/pull/57355#discussion_r3689561707


##########
core/src/main/java/org/apache/spark/shuffle/api/metric/CustomShuffleMetric.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.shuffle.api.metric;
+
+import org.apache.spark.annotation.Private;
+
+/**
+ * :: Private ::
+ * A custom shuffle metric.
+ *
+ * @since 4.3.0
+ */
+@Private
+public interface CustomShuffleMetric {
+
+  enum MetricType {

Review Comment:
   Could we align this contract with DSv2 `CustomMetric` and let the plugin 
aggregate its task values? These enum values expose `SQLMetric` rendering 
categories through the shuffle SPI, so implementors need internal SQL metric 
knowledge and cannot represent aggregation such as max or average. A 
plugin-owned `aggregateTaskMetrics(long[])` contract would keep this API 
independent of the internal accumulator model.



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/ShuffleExchangeExec.scala:
##########
@@ -550,16 +561,29 @@ object ShuffleExchangeExec {
     dependency
   }
 
+  /** Backward-compatible overload for callers that do not report custom 
shuffle metrics. */
+  def createShuffleWriteProcessor(metrics: Map[String, SQLMetric]): 
ShuffleWriteProcessor = {
+    createShuffleWriteProcessor(metrics, Map.empty)
+  }
+
   /**
    * Create a customized [[ShuffleWriteProcessor]] for SQL which wrap the 
default metrics reporter
-   * with [[SQLShuffleWriteMetricsReporter]] as new reporter for 
[[ShuffleWriteProcessor]].
+   * with [[SQLShuffleWriteMetricsReporter]] as new reporter for 
[[ShuffleWriteProcessor]], and
+   * reports any custom shuffle metrics into `customWriteMetrics`.

Review Comment:
   Please make this sentence grammatically parallel: `Creates a customized 
ShuffleWriteProcessor for SQL that wraps the default metrics reporter with 
SQLShuffleWriteMetricsReporter and reports any custom shuffle metrics to 
customWriteMetrics.`



##########
core/src/main/java/org/apache/spark/shuffle/api/metric/CustomShuffleTaskMetric.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.shuffle.api.metric;
+
+import org.apache.spark.annotation.Private;
+
+/**
+ * :: Private ::
+ * A per-task value for a {@link CustomShuffleMetric}.
+ *
+ * @since 4.3.0
+ */
+@Private
+public interface CustomShuffleTaskMetric {
+
+  /**
+   * The name of this metric. Must match the name of the declaring {@link 
CustomShuffleMetric}.
+   */
+  String name();
+
+  /**
+   * Returns the long value of custom shuffle task metric.

Review Comment:
   ```suggestion
      * Returns the value of this custom shuffle task metric.
   ```



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