Use combineByKey to get output as (key, iterable[values])

前端 未结 1 1250
我在风中等你
我在风中等你 2020-12-22 12:34

I am trying to transform RDD(key,value) to RDD(key,iterable[value]), same as output returned by the groupByKey method. But as

1条回答
  •  自闭症患者
    2020-12-22 13:29

    If you want a output similar from what groupByKey will give you, then you should absolutely use groupByKey and not some other method. The reduceByKey, combineByKey, etc. are only more efficient compared to using groupByKey followed with an aggregation (giving you the same result as one of the other groupBy methods could have given).

    As the wanted result is an RDD[key,iterable[value]], building the list yourself or letting groupByKey do it will result in the same amount of work. There is no need to reimplement groupByKey yourself. The problem with groupByKey is not its implementation but lies in the distributed architecture.

    For more information regarding groupByKey and these types of optimizations, I would recommend reading more here.

    0 讨论(0)
提交回复
热议问题