Github user davies commented on the pull request:
https://github.com/apache/spark/pull/7378#issuecomment-121705689
@njhwang @JoshRosen The reason we need to do deepcopy here is that the two
mapPartition() will be combined together as a single task. When the closure is
serialized by pickle, the zeroValue will be memorized by Pickler, and
deserialized as single object for two mapParition(). It's weird to call fold()
inside aggregate(), because it does not need to run `combOp` on each partition,
it should be change to:
```
return reduce(combOp, self.mapPartitions(func).collect(), zeroValue)
```
Then we don't need to do the deep copy (deep copy may fail in some cases,
for example, object from C extension).
---
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]