Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kiszk committed Mar 8, 2017
1 parent 1f9ece4 commit dfbce2a
Showing 1 changed file with 27 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,30 +219,33 @@ case class MapElementsExec(
override def doConsume(ctx: CodegenContext, input: Seq[ExprCode], row: ExprCode): String = {
val (funcClass, methodName) = func match {
case m: MapFunction[_, _] => classOf[MapFunction[_, _]] -> "call"
case _ =>
(if (child.output.length == 1) child.output(0).dataType else NullType,
outputObjAttr.dataType) match {
// if a pair of an argument and return types is one of specific types
// whose specialized method (apply$mc..$sp) is generated by scalac,
// Catalyst generated a direct method call to the specialized method.
case (IntegerType, IntegerType) => classOf[Int => Int] -> "apply$mcII$sp"
case (IntegerType, LongType) => classOf[Int => Long] -> "apply$mcJI$sp"
case (IntegerType, FloatType) => classOf[Int => Float] -> "apply$mcFI$sp"
case (IntegerType, DoubleType) => classOf[Int => Double] -> "apply$mcDI$sp"
case (LongType, IntegerType) => classOf[Long => Int] -> "apply$mcIJ$sp"
case (LongType, LongType) => classOf[Long => Long] -> "apply$mcJJ$sp"
case (LongType, FloatType) => classOf[Long => Float] -> "apply$mcFJ$sp"
case (LongType, DoubleType) => classOf[Long => Double] -> "apply$mcDJ$sp"
case (FloatType, IntegerType) => classOf[Float => Int] -> "apply$mcIF$sp"
case (FloatType, LongType) => classOf[Float => Long] -> "apply$mcJF$sp"
case (FloatType, FloatType) => classOf[Float => Float] -> "apply$mcFF$sp"
case (FloatType, DoubleType) => classOf[Float => Double] -> "apply$mcDF$sp"
case (DoubleType, IntegerType) => classOf[Double => Int] -> "apply$mcID$sp"
case (DoubleType, LongType) => classOf[Double => Long] -> "apply$mcJD$sp"
case (DoubleType, FloatType) => classOf[Double => Float] -> "apply$mcFD$sp"
case (DoubleType, DoubleType) => classOf[Double => Double] -> "apply$mcDD$sp"
case _ => classOf[Any => Any] -> "apply"
}
case _ => (child.output(0).dataType, outputObjAttr.dataType) match {
// if a pair of an argument and return types is one of specific types
// whose specialized method (apply$mc..$sp) is generated by scalac,
// Catalyst generated a direct method call to the specialized method.
// The followings are references for this specialization:
// https://github.com/scala/scala/blob/2.11.x/src/compiler/scala/tools/nsc/transform/
// SpecializeTypes.scala
// http://www.cakesolutions.net/teamblogs/scala-dissection-functions
// http://axel22.github.io/2013/11/03/specialization-quirks.html
case (IntegerType, IntegerType) => classOf[Int => Int] -> "apply$mcII$sp"
case (IntegerType, LongType) => classOf[Int => Long] -> "apply$mcJI$sp"
case (IntegerType, FloatType) => classOf[Int => Float] -> "apply$mcFI$sp"
case (IntegerType, DoubleType) => classOf[Int => Double] -> "apply$mcDI$sp"
case (LongType, IntegerType) => classOf[Long => Int] -> "apply$mcIJ$sp"
case (LongType, LongType) => classOf[Long => Long] -> "apply$mcJJ$sp"
case (LongType, FloatType) => classOf[Long => Float] -> "apply$mcFJ$sp"
case (LongType, DoubleType) => classOf[Long => Double] -> "apply$mcDJ$sp"
case (FloatType, IntegerType) => classOf[Float => Int] -> "apply$mcIF$sp"
case (FloatType, LongType) => classOf[Float => Long] -> "apply$mcJF$sp"
case (FloatType, FloatType) => classOf[Float => Float] -> "apply$mcFF$sp"
case (FloatType, DoubleType) => classOf[Float => Double] -> "apply$mcDF$sp"
case (DoubleType, IntegerType) => classOf[Double => Int] -> "apply$mcID$sp"
case (DoubleType, LongType) => classOf[Double => Long] -> "apply$mcJD$sp"
case (DoubleType, FloatType) => classOf[Double => Float] -> "apply$mcFD$sp"
case (DoubleType, DoubleType) => classOf[Double => Double] -> "apply$mcDD$sp"
case _ => classOf[Any => Any] -> "apply"
}
}
val funcObj = Literal.create(func, ObjectType(funcClass))
val callFunc = Invoke(funcObj, methodName, outputObjAttr.dataType, child.output)
Expand Down

0 comments on commit dfbce2a

Please sign in to comment.