HyukjinKwon 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_r241937089
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala
##########
@@ -57,9 +57,29 @@ object Row {
/**
* Merge multiple rows into a single row, one after another.
*/
+
+ @deprecated("This method is deprecated and will be removed in future
versions.", "3.0.0")
def merge(rows: Row*): Row = {
- // TODO: Improve the performance of this if used in performance critical
part.
- new GenericRow(rows.flatMap(_.toSeq).toArray)
+ var fSize, sSize = rows.size
+ var number = 0
+
+ while (fSize != 0) {
+ fSize -= 1
+ number += rows(fSize).size
+ }
+
+ val container = Array.ofDim[Any](number)
+
+ while (sSize != 0) {
+ sSize -= 1
+ var ssSize = rows(sSize).size
+ while (ssSize != 0) {
+ number -= 1
+ ssSize -= 1
+ container(number) = rows(sSize)(ssSize)
+ }
+ }
Review comment:
I would just leave the function as was. It will be removed in the next
release anyway.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]