首页 > 其他 > 详细

spark:join与cogroup

时间:2020-05-20 10:25:14      阅读:70      评论:0      收藏:0      [点我收藏+]

1.RDD[K,V],键值对类型的rdd的函数在PairRDDFunctions这个类中

rdd类中,通过隐士转换让rdd有了PairRDDFunctions这个类里面方法的功能

技术分享图片

 

 

 

技术分享图片

 2.rdd 的join方式

1.join=》rdd[k,v] join rdd[k,w]=》RDD[(K, (V, W))] 

def join[W](other: RDD[(K, W)], partitioner: Partitioner): RDD[(K, (V, W))]
2.leftOuterJoin 右边有可能是空的所有
rdd[k,v] leftOuterJoin rdd[k,w]=》RDD[(K, (V, Option[W]))]
def leftOuterJoin[W](other: RDD[(K, W)], partitioner: Partitioner): RDD[(K, (V, Option[W]))]
3全join=》RDD[(K, (Option[V], Option[W]))]
def fullOuterJoin[W]( other: RDD[(K, W)],numPartitions: Int): RDD[(K, (Option[V], Option[W]))]
4.cogroup=》RDD[(K, (Iterable[V], Iterable[W]))]
def cogroup[W](other: RDD[(K, W)], partitioner: Partitioner): RDD[(K, (Iterable[V], Iterable[W]))]

技术分享图片

join的底层调用cgroup算子

 3.cogroup算子

技术分享图片

 

 

 测试看一下啥结果

技术分享图片

 

spark:join与cogroup

原文:https://www.cnblogs.com/hejunhong/p/12906231.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!