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 2019/05/01 15:17:39 UTC

[GitHub] [spark] srowen commented on a change in pull request #24505: [SPARK-27607][SQL] Improve Row.toString performance

srowen commented on a change in pull request #24505: [SPARK-27607][SQL] Improve Row.toString performance
URL: https://github.com/apache/spark/pull/24505#discussion_r280104222
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
 ##########
 @@ -465,16 +465,34 @@ trait Row extends Serializable {
   }
 
   /** Displays all elements of this sequence in a string (without a separator). */
-  def mkString: String = toSeq.mkString
+  def mkString: String = mkString("")
 
   /** Displays all elements of this sequence in a string using a separator string. */
-  def mkString(sep: String): String = toSeq.mkString(sep)
+  def mkString(sep: String): String = mkString("", sep, "")
 
   /**
    * Displays all elements of this traversable or iterator in a string using
    * start, end, and separator strings.
    */
-  def mkString(start: String, sep: String, end: String): String = toSeq.mkString(start, sep, end)
+  def mkString(start: String, sep: String, end: String): String = {
+    var first = true
+    var i = 0
+    val n = length
+    val builder = new StringBuilder
+    builder.append(start)
+    while (i < n) {
+      if (first) {
 
 Review comment:
   Yeah this could also remove one more line of code with ...
   ```
   if (i > 0) {
     builder.append(sep)
   }
   builder.append(get(i))
   ```

----------------------------------------------------------------
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


With regards,
Apache Git Services

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