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 2021/08/04 23:49:40 UTC
[GitHub] [spark] akpatnam25 commented on a change in pull request #33644: [SPARK-36419][CORE]: Optionally move final aggregation in RDD.treeAggregate to executor
akpatnam25 commented on a change in pull request #33644:
URL: https://github.com/apache/spark/pull/33644#discussion_r683031421
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1233,6 +1233,21 @@ abstract class RDD[T: ClassTag](
(i, iter) => iter.map((i % curNumPartitions, _))
}.foldByKey(zeroValue, new HashPartitioner(curNumPartitions))(cleanCombOp).values
}
+ if (conf.get(ENABLE_EXECUTOR_TREE_AGGREGATE) && partiallyAggregated.partitions.length > 1) {
+ // define a new partitioner that results in only 1 partition
+ val constantPartitioner = new Partitioner {
+ override def numPartitions: Int = 1
+
+ override def getPartition(key: Any): Int = 0
+ }
+ // map the partially aggregated rdd into a key-value rdd
+ // do the computation in the single executor with one partition
+ // get the new RDD[U]
+ partiallyAggregated = partiallyAggregated
+ .map(v => (0.toByte, v))
+ .foldByKey(zeroValue, constantPartitioner)(cleanCombOp)
+ .values
+ }
val copiedZeroValue = Utils.clone(zeroValue, sc.env.closureSerializer.newInstance())
Review comment:
no it would not submit another job, because there is only one partition. spark would do the fold internal the partition (we only have 1 in this case), and return.
As described on Apache Spark's website the fold definition states:
```
"Aggregate the elements of each partition, and then the results for all the partitions, using a given associative function and a neutral "zero value"."
```
Thus fold operates by folding first each element of partition and then the result of partition
it is partition dependent
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org