3-spark学习笔记-SparkAPI
生活随笔
收集整理的這篇文章主要介紹了
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等等
總結
以上是生活随笔為你收集整理的3-spark学习笔记-SparkAPI的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2-spark学习笔记-spark发展概
- 下一篇: 开启大数据时代谷歌三篇论文-BigTab