Skip to content
Snippets Groups Projects
Commit 0fff5c6e authored by Reynold Xin's avatar Reynold Xin
Browse files

[SPARK-13130][SQL] Make codegen variable names easier to read

1. Use lower case
2. Change long prefixes to something shorter (in this case I am changing only one: TungstenAggregate -> agg).

Author: Reynold Xin <rxin@databricks.com>

Closes #11017 from rxin/SPARK-13130.
parent 0df3cfb8
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.codegen._
import org.apache.spark.sql.catalyst.plans.physical.Partitioning
import org.apache.spark.sql.catalyst.rules.Rule
import org.apache.spark.sql.execution.aggregate.TungstenAggregate
import org.apache.spark.util.Utils
/**
......@@ -33,6 +34,12 @@ import org.apache.spark.util.Utils
*/
trait CodegenSupport extends SparkPlan {
/** Prefix used in the current operator's variable names. */
private def variablePrefix: String = this match {
case _: TungstenAggregate => "agg"
case _ => nodeName.toLowerCase
}
/**
* Whether this SparkPlan support whole stage codegen or not.
*/
......@@ -53,7 +60,7 @@ trait CodegenSupport extends SparkPlan {
*/
def produce(ctx: CodegenContext, parent: CodegenSupport): String = {
this.parent = parent
ctx.freshNamePrefix = nodeName
ctx.freshNamePrefix = variablePrefix
doProduce(ctx)
}
......@@ -94,7 +101,7 @@ trait CodegenSupport extends SparkPlan {
child: SparkPlan,
input: Seq[ExprCode],
row: String = null): String = {
ctx.freshNamePrefix = nodeName
ctx.freshNamePrefix = variablePrefix
if (row != null) {
ctx.currentVars = null
ctx.INPUT_ROW = row
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment