RDD和sparksql的求分组topN
RDD
16、计算出每个地区的地点人数最多的前3名?
studentRDD.map(line => (line._4,line._7.toInt))
.groupByKey()
.map(line => {
(line._1, line.2.toList.sortWith( > _).take(3)) //按照降序进行排列
}).collect().foreach(println...
原创
2020-04-24 09:59:44 ·
277 阅读 ·
0 评论