[GitHub] [spark] sunchao commented on a change in pull request #32507: [SPARK-35361][SQL] Improve performance for ApplyFunctionExpression

2021-05-12 Thread GitBox


sunchao commented on a change in pull request #32507:
URL: https://github.com/apache/spark/pull/32507#discussion_r630761810



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ApplyFunctionExpression.scala
##
@@ -30,10 +30,11 @@ case class ApplyFunctionExpression(
   override def dataType: DataType = function.resultType()
 
   private lazy val reusedRow = new GenericInternalRow(children.size)
+  private lazy val childrenWithIndex = children.zipWithIndex
 
   /** Returns the result of evaluating this expression on a given input Row */
   override def eval(input: InternalRow): Any = {
-children.zipWithIndex.foreach {
+childrenWithIndex.foreach {

Review comment:
   Running benchmarks now. Let's see.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] sunchao commented on a change in pull request #32507: [SPARK-35361][SQL] Improve performance for ApplyFunctionExpression

2021-05-12 Thread GitBox


sunchao commented on a change in pull request #32507:
URL: https://github.com/apache/spark/pull/32507#discussion_r630756317



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ApplyFunctionExpression.scala
##
@@ -30,10 +30,11 @@ case class ApplyFunctionExpression(
   override def dataType: DataType = function.resultType()
 
   private lazy val reusedRow = new GenericInternalRow(children.size)
+  private lazy val childrenWithIndex = children.zipWithIndex
 
   /** Returns the result of evaluating this expression on a given input Row */
   override def eval(input: InternalRow): Any = {
-children.zipWithIndex.foreach {
+childrenWithIndex.foreach {

Review comment:
   Sure I can give it a try later if you have strong opinion on this. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] sunchao commented on a change in pull request #32507: [SPARK-35361][SQL] Improve performance for ApplyFunctionExpression

2021-05-12 Thread GitBox


sunchao commented on a change in pull request #32507:
URL: https://github.com/apache/spark/pull/32507#discussion_r630751708



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ApplyFunctionExpression.scala
##
@@ -30,10 +30,11 @@ case class ApplyFunctionExpression(
   override def dataType: DataType = function.resultType()
 
   private lazy val reusedRow = new GenericInternalRow(children.size)
+  private lazy val childrenWithIndex = children.zipWithIndex
 
   /** Returns the result of evaluating this expression on a given input Row */
   override def eval(input: InternalRow): Any = {
-children.zipWithIndex.foreach {
+childrenWithIndex.foreach {

Review comment:
   I'm not sure if this is very useful. After the change the cost of the 
loop is negligible:
   
   https://user-images.githubusercontent.com/506679/117926975-6c8a7900-b2ae-11eb-9f2b-9b40f0873115.png;>
   
   Plus I think `foreach` is easier to read.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org