[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
This commit is contained in:
Cheng Hao 2014-05-07 16:54:58 -04:00 committed by Reynold Xin
parent 3308722ca0
commit ca43186867

View file

@ -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