1、map和flatMap的区别
理解
val words: RDD[String] = lines.flatMap(_.split(","))
2、reduce和reduceByKey
理解
val reduced: RDD[(String, Int)] = wordAndOne.reduceByKey((x,y) => {x + y})
val reduced:RDD[(String, Int)] = wordAndOne.reduceByKey(+)
尝试用reduce方法实现reduceByKey的功能
3、sortBy和sortByKey
理解
reduced.sortBy(_._2, false)
4、collect方法
5、sparkstream关键点在于读数据
val lines = ssc.socketTextStream(“hdp-1”, 9999)
来源:CSDN
作者:lucasmaluping
链接:https://blog.csdn.net/lucasmaluping/article/details/103222152