Spark—WordCount

 

 

 

本地模式

import org.apache.spark.SparkContext
import org.apache.spark.SparkConf

object WordCount {
  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName("WordCount").setMaster("local[2]")
    val sc = new SparkContext(conf)   
    val inputFile = sc.textFile("/user/wd")
    val wordCount = inputFile.flatMap(_.split(" ")).map(word => (word, 1)).reduceByKey((a, b) => a + b)
    wordCount.foreach(println)
    sc.stop()
  }
}

 

Spark—WordCount

上一篇:配置.bashrc文件使nvm根据.nvmrc中指定的node版本自动切换


下一篇:selenium 处理date控件