Skip to content

Commit f21f6ce

Browse files
juliuszsompolskigatorsmile
authored andcommitted
[SPARK-22103][FOLLOWUP] Rename addExtraCode to addInnerClass
## What changes were proposed in this pull request? Address PR comments that appeared post-merge, to rename `addExtraCode` to `addInnerClass`, and not count the size of the inner class to the size of the outer class. ## How was this patch tested? YOLO. Author: Juliusz Sompolski <[email protected]> Closes #19353 from juliuszsompolski/SPARK-22103followup.
1 parent 64fbd1c commit f21f6ce

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class CodegenContext {
243243
mutable.Map(outerClassName -> mutable.Map.empty[String, String])
244244

245245
// Verbatim extra code to be added to the OuterClass.
246-
private val extraCode: mutable.ListBuffer[String] = mutable.ListBuffer[String]()
246+
private val extraClasses: mutable.ListBuffer[String] = mutable.ListBuffer[String]()
247247

248248
// Returns the size of the most recently added class.
249249
private def currClassSize(): Int = classSize(classes.head._1)
@@ -332,19 +332,18 @@ class CodegenContext {
332332
}
333333

334334
/**
335-
* Emits any source code added with addExtraCode
335+
* Emits extra inner classes added with addExtraCode
336336
*/
337337
def emitExtraCode(): String = {
338-
extraCode.mkString("\n")
338+
extraClasses.mkString("\n")
339339
}
340340

341341
/**
342342
* Add extra source code to the outermost generated class.
343-
* @param code verbatim source code to be added.
343+
* @param code verbatim source code of the inner class to be added.
344344
*/
345-
def addExtraCode(code: String): Unit = {
346-
extraCode.append(code)
347-
classSize(outerClassName) += code.length
345+
def addInnerClass(code: String): Unit = {
346+
extraClasses.append(code)
348347
}
349348

350349
final val JAVA_BOOLEAN = "boolean"

sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ case class HashAggregateExec(
621621
}
622622
} else ""
623623
}
624-
ctx.addExtraCode(generateGenerateCode())
624+
ctx.addInnerClass(generateGenerateCode())
625625

626626
val doAgg = ctx.freshName("doAggregateWithKeys")
627627
val peakMemory = metricTerm(ctx, "peakMemory")

0 commit comments

Comments
 (0)