-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26504][SQL] Rope-wise dumping of Spark plans #23406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
de38cf8
af5c9ed
0a36a26
07ae72d
f621de7
ca4aed8
d727959
544b80e
059dcf4
fe3bbcf
707c80b
074e9b8
29b62bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ package org.apache.spark.sql.catalyst.util | |
|
|
||
| import java.util.regex.{Pattern, PatternSyntaxException} | ||
|
|
||
| import scala.collection.mutable.ArrayBuffer | ||
|
|
||
| import org.apache.spark.sql.AnalysisException | ||
| import org.apache.spark.unsafe.types.UTF8String | ||
|
|
||
|
|
@@ -87,4 +89,34 @@ object StringUtils { | |
| } | ||
| funcNames.toSeq | ||
| } | ||
|
|
||
| /** | ||
| * Concatenation of sequence of strings to final string with cheap append method | ||
| * and one memory allocation for the final string. | ||
| */ | ||
| class StringConcat { | ||
| private val strings = new ArrayBuffer[String] | ||
| private var length: Int = 0 | ||
|
|
||
| /** | ||
| * Appends a string and accumulates its length to allocate a string buffer for all | ||
| * appended strings once in the toString method. | ||
| */ | ||
| def append(s: String): Unit = { | ||
| if (s != null) { | ||
| strings.append(s) | ||
| length += s.length | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The method allocates memory for all appended strings, writes them to the memory and | ||
| * returns concatenated string. | ||
| */ | ||
| override def toString: String = { | ||
| val result = new StringBuffer(length) | ||
|
||
| strings.foreach(result.append) | ||
| result.toString | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if
StringConcatenationis a better name for this class, as this class is technically a rope (that is a binary tree).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringRopelooks nicer ;-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and is wrong :P...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringConcat?