mapValues
针对Key,Value数据中的Value进行map操作,而不是对key进行处理

mapValues
combineByKey
聚集相同Key的RDD,值形成序列返回

combineByKey
def combineByKey[C](
createCombiner:V=>C, mergeValue:(C,V)=>C, mergeCombiners:(C,C)=>C, partitioner:Partitioner, mapSideCombine:Boolean=true, serializer:Serializer=null):RDD[(K,C)]=self.withScope{
combineByKeyWithClassTag(createCombiner,mergeValue,mergeCombiners,
partitioner,mapSideCombine,serializer)(null)
}
createCombiner:V=>C
在C不存在的情况下,通过V创建seqC
mergeValue:(C,V)=>C
在C已经存在的情况下,需要merge,如把item V加到seqC中
mergeCombiners:(C,C)=>C
合并两个C
partitioner:Partitioner
分区器
mapSideCombine:Boolean=true开启map端combine,减少shuffle传输量
serializer:Serializer=null传输需要序列化,序列化类
reduceByKey
聚集key相同的RDD,值合并

reduceByKey
partitionBy
对RDD进行分区操作
如果原有的RDD分区器和现有分区器相同,不重分区

partitionBy
cogroup
将两个RDD协同划分
对两个RDD中的key-value类型的元素,每个RDD相同key的元素分别聚合一个集合,返回两个RDD中对应key的元素迭代器

cogroup
join
对两个需要连接的RDD进行cogroup操作,形成的新的RDD,对Key下的元素进行笛卡尔积操作,最后返回RDD[(K,(V, W))]
this.cogroup(other, partitioner).flatMapValues { case (vs, ws) => for (v <- vs; w <- ws) yield(v, w)
}

join
leftOutJoin, rightOutJoin
相当于在join的基础上先判断一侧的RDD元素是否为空,如果为空,填充为空。如果不为空,将数据进行连接运算
leftOutJoinif(ws.isEmpty) {
vs.map(v=>(v, None))
} else { for(v <- vs; w <- ws) yield (v, Some(w))
}
作者:Alex90
链接:https://www.jianshu.com/p/3946a395b897
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1294/viewspace-2819255/ ,如需转载,请注明出处,否则将追究法律责任。