This is an automated email from the ASF dual-hosted git repository.

beliefer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 295625e0b4 [GLUTEN-11191][CORE] Refactor leafInputMetricsUpdater for 
WholeStageTransformer (#11192)
295625e0b4 is described below

commit 295625e0b47ba9ba902c77f97ee0f1ae55e58b79
Author: Jiaan Geng <[email protected]>
AuthorDate: Wed Nov 26 17:44:40 2025 +0800

    [GLUTEN-11191][CORE] Refactor leafInputMetricsUpdater for 
WholeStageTransformer (#11192)
---
 .../gluten/execution/WholeStageTransformer.scala       | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git 
a/gluten-substrait/src/main/scala/org/apache/gluten/execution/WholeStageTransformer.scala
 
b/gluten-substrait/src/main/scala/org/apache/gluten/execution/WholeStageTransformer.scala
index 5848985be9..8ced5aa45c 100644
--- 
a/gluten-substrait/src/main/scala/org/apache/gluten/execution/WholeStageTransformer.scala
+++ 
b/gluten-substrait/src/main/scala/org/apache/gluten/execution/WholeStageTransformer.scala
@@ -45,7 +45,6 @@ import org.apache.hadoop.fs.viewfs.ViewFileSystemUtils
 
 import scala.collection.JavaConverters._
 import scala.collection.mutable
-import scala.collection.mutable.ArrayBuffer
 
 case class TransformContext(outputAttributes: Seq[Attribute], root: RelNode)
 
@@ -417,20 +416,11 @@ case class WholeStageTransformer(child: SparkPlan, 
materializeInput: Boolean = f
   }
 
   private def leafInputMetricsUpdater(): InputMetricsWrapper => Unit = {
-    def collectLeaves(plan: SparkPlan, buffer: ArrayBuffer[TransformSupport]): 
Unit = {
-      plan match {
-        case node: TransformSupport if 
node.children.forall(!_.isInstanceOf[TransformSupport]) =>
-          buffer.append(node)
-        case node: TransformSupport =>
-          node.children
-            .foreach(collectLeaves(_, buffer))
-        case _ =>
-      }
+    val leaves = child.collect {
+      case plan: TransformSupport if 
plan.children.forall(!_.isInstanceOf[TransformSupport]) =>
+        plan
     }
-
-    val leafBuffer = new ArrayBuffer[TransformSupport]()
-    collectLeaves(child, leafBuffer)
-    val leafMetricsUpdater = leafBuffer.map(_.metricsUpdater())
+    val leafMetricsUpdater = leaves.map(_.metricsUpdater())
 
     (inputMetrics: InputMetricsWrapper) => {
       leafMetricsUpdater.foreach(_.updateInputMetrics(inputMetrics))


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to