1、官方解释
1.1、flatMap
<U> JavaRDD<U> flatMap(FlatMapFunction<T,U> f)Return a new RDD by first applying a function to all elements of this RDD, and then flattening the results.
Parameters:
f- (undocumented)Returns:
(undocumented)
此解释为输入必须是一个RDD,输出也将是一个RDD,并且输出的时候必须是一个数据集合
map和flatMap对比图如下(个人的一些理解,有不对的地方请大家指正。)

1.2、mapToPair
<K2,V2> JavaPairRDD<K2,V2> mapToPair(PairFunction<T,K2,V2> f)Return a new RDD by applying a function to all elements of this RDD.
Parameters:
f- (undocumented)Returns:
(undocumented)
此解释为会对一个RDD中的每个元素调用f函数,其中原来RDD中的每一个元素都是T类型的,调用f函数后会进行一定的操作把每个元素都转换成一个<K2,V2>类型的对象
1.3、reduceByKey
public JavaPairRDD<K,V> reduceByKey(

最低0.47元/天 解锁文章
1583

被折叠的 条评论
为什么被折叠?



