You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/05/13 01:14:17 UTC

[GitHub] [spark] maropu commented on a change in pull request #32527: [SPARK-35384][SQL] Improve performance for InvokeLike.invoke

maropu commented on a change in pull request #32527:
URL: https://github.com/apache/spark/pull/32527#discussion_r631499051



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -127,13 +128,19 @@ trait InvokeLike extends Expression with NonSQLExpression {
       arguments: Seq[Expression],
       input: InternalRow,
       dataType: DataType): Any = {
-    val args = arguments.map(e => e.eval(input).asInstanceOf[Object])
-    if (needNullCheck && args.exists(_ == null)) {
+    var i = 0
+    val len = arguments.length
+    while (i < len) {
+      val e = arguments(i)

Review comment:
       It looks we don't need this intermediate val?
   ```
   evaluatedArgs(i) = arguments(i).eval(input).asInstanceOf[Object]
   ```

##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -127,13 +128,19 @@ trait InvokeLike extends Expression with NonSQLExpression {
       arguments: Seq[Expression],
       input: InternalRow,
       dataType: DataType): Any = {
-    val args = arguments.map(e => e.eval(input).asInstanceOf[Object])
-    if (needNullCheck && args.exists(_ == null)) {
+    var i = 0
+    val len = arguments.length
+    while (i < len) {
+      val e = arguments(i)
+      evaluatedArgs(i) = e.eval(input).asInstanceOf[Object]
+      i += 1
+    }
+    if (needNullCheck && evaluatedArgs.exists(_ == null)) {

Review comment:
       nit: my IDE suggests `.exists(_ == null)` -> `.contains(null)`




-- 
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:
users@infra.apache.org



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