You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by rx...@apache.org on 2016/02/02 08:08:18 UTC

spark git commit: [SPARK-13130][SQL] Make codegen variable names easier to read

Repository: spark
Updated Branches:
  refs/heads/master 0df3cfb8a -> 0fff5c6e6


[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 <rx...@databricks.com>

Closes #11017 from rxin/SPARK-13130.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/0fff5c6e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/0fff5c6e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/0fff5c6e

Branch: refs/heads/master
Commit: 0fff5c6e6325357a241d311e72db942c4850af34
Parents: 0df3cfb
Author: Reynold Xin <rx...@databricks.com>
Authored: Mon Feb 1 23:08:11 2016 -0800
Committer: Reynold Xin <rx...@databricks.com>
Committed: Mon Feb 1 23:08:11 2016 -0800

----------------------------------------------------------------------
 .../apache/spark/sql/execution/WholeStageCodegen.scala   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/0fff5c6e/sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegen.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegen.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegen.scala
index ef81ba6..02b0f42 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegen.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegen.scala
@@ -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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org