spark:join与cogroup

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算子

 测试看一下啥结果

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