Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/19811#discussion_r157110933
--- 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();")
--- End diff --
I think we don't have too many `UnsafeExternalRowSorter`, it should be
inlined?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]