-
- Downloads
[SPARK-15748][SQL] Replace inefficient foldLeft() call with flatMap() in PartitionStatistics
`PartitionStatistics` uses `foldLeft` and list concatenation (`++`) to flatten an iterator of lists, but this is extremely inefficient compared to simply doing `flatMap`/`flatten` because it performs many unnecessary object allocations. Simply replacing this `foldLeft` by a `flatMap` results in decent performance gains when constructing PartitionStatistics instances for tables with many columns. This patch fixes this and also makes two similar changes in MLlib and streaming to try to fix all known occurrences of this pattern. Author: Josh Rosen <joshrosen@databricks.com> Closes #13491 from JoshRosen/foldleft-to-flatmap.
Showing
- mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala 1 addition, 1 deletion...b/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala
- sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/ColumnStats.scala 2 additions, 2 deletions...org/apache/spark/sql/execution/columnar/ColumnStats.scala
- streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingPage.scala 2 additions, 2 deletions...n/scala/org/apache/spark/streaming/ui/StreamingPage.scala
Please register or sign in to comment