Github user cloud-fan commented on the pull request: https://github.com/apache/spark/pull/7018#issuecomment-115298005 the benchmark (ScalaUdf will convert from catalyst to scala and back again): ```scala case class Floor(child: Expression) extends UnaryExpression with Predicate { override def toString = s"Floor $child" override def eval(input: InternalRow): Any = { child.eval(input) match { case null => null case s: Seq[Int] => s.sum } } } object T { def benchmark(count: Int, expr: Expression): Unit = { var i = 0 val row = new GenericRow(Array[Any]((1 to 10).toSeq)) val s = System.currentTimeMillis() while (i < count) { expr.eval(row) i += 1 } val e = System.currentTimeMillis() println (s"${expr.getClass.getSimpleName} -- ${e - s} ms") } def main(args: Array[String]) { def func(s: Seq[Int]) = s.sum val attr = BoundReference(0, ArrayType(IntegerType), true) val udf0 = ScalaUdf(func _, IntegerType, attr :: Nil) val udf1 = Floor(attr) benchmark(1000000, udf0) benchmark(1000000, udf0) benchmark(1000000, udf0) benchmark(1000000, udf1) benchmark(1000000, udf1) benchmark(1000000, udf1) } } ``` before: ScalaUdf -- 321 ms ScalaUdf -- 313 ms ScalaUdf -- 232 ms Floor -- 40 ms Floor -- 7 ms Floor -- 7 ms after: ScalaUdf -- 73 ms ScalaUdf -- 26 ms ScalaUdf -- 23 ms Floor -- 34 ms Floor -- 7 ms Floor -- 7 ms
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org