标签:contex atm .text line reduce local app text split
object WordCount {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("WordCount").setMaster("local[*]")
    val sc = new SparkContext(conf)
    val lines: RDD[String] = sc.textFile("/Users/yaoyao/hobby/AntiReptile/ip/wordcount.txt")
    val words: RDD[String] = lines.flatMap(_.split(" "))
    val wordOne: RDD[(String, Int)] = words.map((_,1))
    val reduces: RDD[(String, Int)] = wordOne.reduceByKey(_+_)
    println(reduces.collect().toBuffer)
    sc.stop()
}
}
标签:contex atm .text line reduce local app text split
原文地址:https://www.cnblogs.com/yaoyao66123/p/9356375.html