Github user mridulm commented on a diff in the pull request:
https://github.com/apache/spark/pull/228#discussion_r11094329
--- Diff: core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala
---
@@ -789,6 +799,25 @@ class DAGScheduler(
}
/**
+ * detect the duplicate accumulator value and save the accumulator values
+ * @param accumValue the accumulator values received from the task
+ * @param stage the stage which the task belongs to
+ * @param task the completed task
+ */
+ private def saveAccumulatorValue(accumValue: Map[Long, Any], stage:
Stage, task: Task[_]) {
+ if (accumValue != null &&
+ (!stageIdToAccumulators.contains(stage.id) ||
+ !stageIdToAccumulators(stage.id).contains(task.partitionId))) {
+ stageIdToAccumulators.getOrElseUpdate(stage.id,
+ new HashMap[Int, ListBuffer[(Long, Any)]]).
+ getOrElseUpdate(task.partitionId, new ListBuffer[(Long, Any)])
+ for ((id, value) <- accumValue) {
+ stageIdToAccumulators(stage.id)(task.partitionId) += id -> value
--- End diff --
nit: you can avoid the lookup within the loop by using the value returned
in the getOrElseUpdate calls.
---
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.
---