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 2018/12/10 22:39:56 UTC

[GitHub] rxin commented on a change in pull request #23271: [SPARK-26318][SQL] Enhance function merge performance in Row

rxin commented on a change in pull request #23271: [SPARK-26318][SQL] Enhance function merge performance in Row
URL: https://github.com/apache/spark/pull/23271#discussion_r240409211
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
 ##########
 @@ -58,8 +58,21 @@ object Row {
    * Merge multiple rows into a single row, one after another.
    */
   def merge(rows: Row*): Row = {
-    // TODO: Improve the performance of this if used in performance critical part.
-    new GenericRow(rows.flatMap(_.toSeq).toArray)
+    val size = rows.size
+    var number = 0
+    for (i <- 0 until size) {
+      number = number + rows(i).size
+    }
+    val container = Array.ofDim[Any](number)
+    var n = 0
+    for (i <- 0 until size) {
 
 Review comment:
   if you want to improve this more, you can try with a while loop here rather than a for loop, without creating the extra 0 until size.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

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