Skip to content

Commit e483ffa

Browse files
committed
Refactor
1 parent 62473ad commit e483ffa

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

spark/src/main/scala/org/apache/comet/ExtendedExplainInfo.scala

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,15 @@ class ExtendedExplainInfo extends ExtendedExplainGenerator {
8686
val planStats = new CometCoverageStats()
8787
val outString = new StringBuilder()
8888
generateTreeString(getActualPlan(plan), 0, Seq(), 0, outString, planStats)
89-
val eligible = planStats.sparkOperators + planStats.cometOperators
90-
val converted =
91-
if (eligible == 0) 0.0 else planStats.cometOperators.toDouble / eligible * 100.0
92-
val summary = s"Comet accelerated ${planStats.cometOperators} out of $eligible " +
93-
s"eligible operators (${converted.toInt}%). " +
94-
s"Final plan contains ${planStats.transitions} transitions."
95-
s"${outString.toString()}\n$summary"
89+
s"${outString.toString()}\n$planStats"
9690
}
9791

9892
/** Get the coverage statistics without the full plan */
9993
def generateCoverageInfo(plan: SparkPlan): String = {
10094
val planStats = new CometCoverageStats()
10195
val outString = new StringBuilder()
10296
generateTreeString(getActualPlan(plan), 0, Seq(), 0, outString, planStats)
103-
val eligible = planStats.sparkOperators + planStats.cometOperators
104-
val converted =
105-
if (eligible == 0) 0.0 else planStats.cometOperators.toDouble / eligible * 100.0
106-
s"Comet accelerated ${planStats.cometOperators} out of $eligible " +
107-
s"eligible operators (${converted.toInt}%). " +
108-
s"Final plan contains ${planStats.transitions} transitions between Spark and Comet."
97+
planStats.toString()
10998
}
11099

111100
// Simplified generateTreeString from Spark TreeNode. Appends explain info to the node if any
@@ -199,6 +188,15 @@ class CometCoverageStats {
199188
var sparkOperators: Int = 0
200189
var cometOperators: Int = 0
201190
var transitions: Int = 0
191+
192+
override def toString(): String = {
193+
val eligible = sparkOperators + cometOperators
194+
val converted =
195+
if (eligible == 0) 0.0 else cometOperators.toDouble / eligible * 100.0
196+
s"Comet accelerated $cometOperators out of $eligible " +
197+
s"eligible operators (${converted.toInt}%). " +
198+
s"Final plan contains $transitions transitions between Spark and Comet."
199+
}
202200
}
203201

204202
object CometExplainInfo {
@@ -213,6 +211,7 @@ object CometExplainInfo {
213211
case p: ReusedExchangeExec => getActualPlan(p.child)
214212
case p => p
215213
}
214+
216215
}
217216

218217
}

0 commit comments

Comments
 (0)