Github user shivaram commented on a diff in the pull request:
https://github.com/apache/spark/pull/9222#discussion_r42883859
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala
---
@@ -130,16 +130,18 @@ private[r] object SQLUtils {
}
def dfToCols(df: DataFrame): Array[Array[Any]] = {
- // localDF is Array[Row]
- val localDF = df.collect()
+ val localDF: Array[Row] = df.collect()
val numCols = df.columns.length
+ val numRows = localDF.length
- // result is Array[Array[Any]]
- (0 until numCols).map { colIdx =>
- localDF.map { row =>
- row(colIdx)
+ val colArray = new Array[Array[Any]](numCols)
+ for (colNo <- 0 until numCols) {
--- End diff --
Using a while loop here instead of a for loop should also help with
performance
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]