Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19811#discussion_r157410191
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/SortExec.scala ---
@@ -133,20 +133,17 @@ case class SortExec(
override def needStopCheck: Boolean = false
override protected def doProduce(ctx: CodegenContext): String = {
- val needToSort = ctx.freshName("needToSort")
- ctx.addMutableState(ctx.JAVA_BOOLEAN, needToSort, s"$needToSort =
true;")
+ val needToSort = ctx.addMutableState(ctx.JAVA_BOOLEAN, "needToSort", v
=> s"$v = true;")
// Initialize the class member variables. This includes the instance
of the Sorter and
// the iterator to return sorted rows.
val thisPlan = ctx.addReferenceObj("plan", this)
- sorterVariable = ctx.freshName("sorter")
- ctx.addMutableState(classOf[UnsafeExternalRowSorter].getName,
sorterVariable,
- s"$sorterVariable = $thisPlan.createSorter();")
- val metrics = ctx.freshName("metrics")
- ctx.addMutableState(classOf[TaskMetrics].getName, metrics,
- s"$metrics = org.apache.spark.TaskContext.get().taskMetrics();")
- val sortedIterator = ctx.freshName("sortedIter")
- ctx.addMutableState("scala.collection.Iterator<UnsafeRow>",
sortedIterator, "")
+ sorterVariable =
ctx.addMutableState(classOf[UnsafeExternalRowSorter].getName, "sorter",
+ v => s"$v = $thisPlan.createSorter();", forceInline = true)
+ val metrics = ctx.addMutableState(classOf[TaskMetrics].getName,
"metrics",
+ v => s"$v = org.apache.spark.TaskContext.get().taskMetrics();",
forceInline = true)
+ val sortedIterator =
ctx.addMutableState("scala.collection.Iterator<UnsafeRow>", "sortedIter",
+ forceInline = true)
--- End diff --
one question: is there any other places like this? do you have a list?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]