标签:for flat pre oca val span The pac put
import org.apache.spark.{SparkConf, SparkContext}
object wc2 {
def main(args: Array[String]): Unit = {
val conf = new SparkConf().setMaster("local").setAppName("wc2")
val sc = new SparkContext(conf)
val inputRdd = sc.textFile("/root/The_Man_of_Property.txt")
val wc = inputRdd.flatMap(_.split(" "))
.map((_,1))
.reduceByKey(_+_)
val sortWords = wc.map(x=>(x._2,x._1))
.sortByKey(false)
.map(x=>(x._2,x._1))
.foreach(println(_))
}
}
标签:for flat pre oca val span The pac put
原文地址:https://www.cnblogs.com/NPC-assange/p/11976964.html