开发者学堂课程【大数据实时计算框架 Spark 快速入门:Spark textFile 和排序-3】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/100/detail/1696
Spark textFile 和排序-3
GroupTopN 相关代码
47@override
48publie Stcing call(Tuple2>tuple)
49throws Exception {
50return tuple._ 1;
51}
52}).collect();
53
54groupedPairs.filter(new Function>, Boolean>() {
55
56private static final long serialVersionUID =1L;
57
58@Override
59public Boolean call(Tuple2>tuple)
60throws Exception {
61return tuple._1. equals(keys.get(0));
62
63}).flatMap(new FlatMapFunctionsTuple> Integer>(){
64});
65
66JavaPairRDD>top2score=groupedPairs
67.mapToPair(new PairFunction>,String, Iterable>() {
68
69private static final long serialVersionUID1L;