2,wordcount:
val wordcount = sc.textFile("/user/s-44/wordcount.txt").flatMap(_.split(‘ ‘)).map((_, 1)).reduceByKey(_ + _).map(_.swap).sortByKey().collect val wordcount = sc.textFile("/user/s-44/wordcount.txt").flatMap(_.split(‘ ‘)).map((_, 1)).reduceByKey(_ + _).map(_.swap).sortByKey().saveAsTextFile("/user/s-44/result.txt")
1,集合变成rdd
val rdd = sc.parallelize(List(1, 2, 3, 4, 5))
时间: 2024-10-28 07:10:09