GitHub user suyanNone opened a pull request:
https://github.com/apache/spark/pull/5259
Accumulator deserialized twice because the NarrowCoGroupSplitDep contains
rdd object.
1. Use code like belows, will found accumulator deserialized twice.
first:
```
task = ser.deserialize[Task[Any]](taskBytes,
Thread.currentThread.getContextClassLoader)
```
second:
```
val (rdd, dep) = ser.deserialize[(RDD[_], ShuffleDependency[_, _, _])](
ByteBuffer.wrap(taskBinary.value),
Thread.currentThread.getContextClassLoader)
```
which the first deserialized is not what expected.
because ResultTask or ShuffleMapTask will have a partition object.
in class
```
CoGroupedRDD[K](@transient var rdds: Seq[RDD[_ <: Product2[K, _]]], part:
Partitioner)
, the CogroupPartition may contains a CoGroupDep:
NarrowCoGroupSplitDep(
rdd: RDD[_],
splitIndex: Int,
var split: Partition
) extends CoGroupSplitDep {
```
in that NarrowCoGroupSplitDep, it will bring into rdd object, which result
into the first deserialized.
example:
```
val acc1 = sc.accumulator(0, "test1")
val acc2 = sc.accumulator(0, "test2")
val rdd1 = sc.parallelize((1 to 10).toSeq, 3)
val rdd2 = sc.parallelize((1 to 10).toSeq, 3)
val combine1 = rdd1.map { case a => (a, 1)}.combineByKey(a => {
acc1 += 1
a
}, (a: Int, b: Int) => {
a + b
},
(a: Int, b: Int) => {
a + b
}, new HashPartitioner(3), mapSideCombine = false)
val combine2 = rdd2.map { case a => (a, 1)}.combineByKey(
a => {
acc2 += 1
a
},
(a: Int, b: Int) => {
a + b
},
(a: Int, b: Int) => {
a + b
}, new HashPartitioner(3), mapSideCombine = false)
combine1.cogroup(combine2, new HashPartitioner(3)).count()
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/suyanNone/spark fix-acc
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/5259.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #5259
----
commit 2fde0669f62053d86adbbb37196fb161fb5ac1c8
Author: hushan[è¡ç] <[email protected]>
Date: 2015-03-30T08:05:02Z
Fix twice deserialized accumulators with CoGroup
----
---
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]