Repository: spark
Updated Branches:
  refs/heads/branch-1.0 18caa8cbc -> 82ceda250


[SQL] Fix Performance Issue in data type casting

Using lazy val object instead of function in the class Cast, which improved the 
performance nearly by 2X in my local micro-benchmark.

Author: Cheng Hao <[email protected]>

Closes #679 from chenghao-intel/fix_type_casting and squashes the following 
commits:

71b0902 [Cheng Hao] using lazy val object instead of function for data type 
casting

(cherry picked from commit ca43186867f0120c29d1b27cfee0c7ff4a107d84)
Signed-off-by: Reynold Xin <[email protected]>


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

Branch: refs/heads/branch-1.0
Commit: 82ceda2504b307c086d5931b3d5bd2362e4046f2
Parents: 18caa8c
Author: Cheng Hao <[email protected]>
Authored: Wed May 7 16:54:58 2014 -0400
Committer: Reynold Xin <[email protected]>
Committed: Wed May 7 16:55:59 2014 -0400

----------------------------------------------------------------------
 .../scala/org/apache/spark/sql/catalyst/expressions/Cast.scala     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/82ceda25/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
----------------------------------------------------------------------
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
index 40d2b42..0b3a4e7 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
@@ -182,7 +182,7 @@ case class Cast(child: Expression, dataType: DataType) 
extends UnaryExpression {
     case x: NumericType => b => x.numeric.asInstanceOf[Numeric[Any]].toFloat(b)
   }
 
-  def cast: Any => Any = dataType match {
+  private lazy val cast: Any => Any = dataType match {
     case StringType => castToString
     case BinaryType => castToBinary
     case DecimalType => castToDecimal

Reply via email to