aboutsummaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorCheng Hao <hao.cheng@intel.com>2014-05-07 16:54:58 -0400
committerReynold Xin <rxin@apache.org>2014-05-07 16:55:59 -0400
commit82ceda2504b307c086d5931b3d5bd2362e4046f2 (patch)
treefc0d764f4b9836ef46a96d461d1b676eb4dee86a /sql
parent18caa8cbc09e2ef2a804f10e42d2939a63b8efd2 (diff)
downloadspark-82ceda2504b307c086d5931b3d5bd2362e4046f2.tar.gz
spark-82ceda2504b307c086d5931b3d5bd2362e4046f2.tar.bz2
spark-82ceda2504b307c086d5931b3d5bd2362e4046f2.zip
[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 <hao.cheng@intel.com> 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 <rxin@apache.org>
Diffstat (limited to 'sql')
-rw-r--r--sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala2
1 files changed, 1 insertions, 1 deletions
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 40d2b42a0c..0b3a4e728e 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