Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1977#discussion_r17681171
  
    --- Diff: python/pyspark/rdd.py ---
    @@ -1588,8 +1599,27 @@ def mergeCombiners(a, b):
                 a.extend(b)
                 return a
     
    -        return self.combineByKey(createCombiner, mergeValue, 
mergeCombiners,
    -                                 numPartitions).mapValues(lambda x: 
ResultIterable(x))
    +        spill = self._can_spill()
    +        memory = self._memory_limit()
    +        serializer = self._jrdd_deserializer
    +        agg = Aggregator(createCombiner, mergeValue, mergeCombiners)
    +
    +        def combine(iterator):
    +            merger = ExternalMerger(agg, memory * 0.9, serializer) \
    +                if spill else InMemoryMerger(agg)
    +            merger.mergeValues(iterator)
    +            return merger.iteritems()
    +
    +        locally_combined = self.mapPartitions(combine)
    +        shuffled = locally_combined.partitionBy(numPartitions)
    +
    +        def groupByKey(it):
    +            merger = ExternalGroupBy(agg, memory, serializer)\
    +                if spill else InMemoryMerger(agg)
    +            merger.mergeCombiners(it)
    +            return merger.iteritems()
    +
    +        return shuffled.mapPartitions(groupByKey).mapValues(ResultIterable)
    --- End diff --
    
    Should we set `preservesPartitioning=True` on this `mapPartitions` call, 
similar to what `combineByKey` does in its final step?


---
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]

Reply via email to