3-spark学习笔记-SparkAPI

API详解如下所示:

具体操作如下所示:

Transformer操作:

1、Map

2、filter

3、flatMap

4、mapPartitions

5、mapPartitionsWithIndex

6、repartition (数据分配不均、性能扩展比较慢,需要repartition 比较消耗资源,进行shuffle操作)

7、coalesce  (减少partition操作 不做shuffle 性能更快速一些 shuffle = false)

8、union

9、join

10、intersection -交集 可以用来算留存

11、cogroup

12、groupBy

13、groupByKey

14、reduceBykey

15、sample   // false 不放回抽样 true放回抽样

16、cartesian 笛卡尔积

17、pipe  //执行上面执行一个shell 命令

18、textFile

val inputRdd = sparkContext.textFile("file_path")

inputRdd.foreach(println(_))

inputRdd.map(_.length).saveAsTextFile("file_path")

Action:

collect、take、first、takesample等等

猜你喜欢

转载自blog.csdn.net/weixin_41362649/article/details/90748270