package streamings.studys

import org.apache.spark.SparkConf
import org.apache.spark.streaming.dstream.DStream
import org.apache.spark.streaming.{Seconds, StreamingContext}

/**
  * Created by yunxinghai on 3/23/2017.
  */
object Case_2_ReadFromLocalFile {

  def main(args: Array[String]): Unit = {

    if (args.length > 2){

      //val master = url

    }else{

      val master = "local[6]"

    }

    val conf = new SparkConf().setAppName("readfile from file local").setMaster("local[6]")

    val ssc = new StreamingContext(conf,Seconds(15))

    val data: DStream[String] = ssc.textFileStream("C:\\p_not_imprt\\Tesst\\")

    val flatData  = data.flatMap(_.split(" "))

    val words = flatData.map((_,1))
    val countEachWord: DStream[(String, Int)] = words.reduceByKey(_+_)


    countEachWord.print()

    ssc.start()
    ssc.awaitTermination()


  }

}

相关文章:

  • 2021-06-19
  • 2021-11-17
  • 2021-06-10
  • 2021-12-18
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2021-08-30
  • 2021-12-12
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案