4.3 高效的算子

groupByKey和reduceByKey

1.groupByKey是没有combine过程
    combineByKeyWithClassTag[CompactBuffer[V]](createCombiner, mergeValue, mergeCombiners, partitioner, mapSideCombine = false)
2.reduceByKey有combine过程
    combineByKeyWithClassTag[V]((v: V) => v, func, func, partitioner) //mapSideCombine默认是true
    1、如果v是数字运算,如wordcount减少网络传输次数
    2、如果v是List[],对v进行收集,因为只收集v所以可以节省空间

注意:reduceByKey不能改变 v 的返回值类型

          两者都可重新指定分区

猜你喜欢

转载自www.cnblogs.com/lybpy/p/9774863.html
4.3