spark streaming 文件系统

package com.immooc.spark

import org.apache.spark.SparkConf
import org.apache.spark.storage.StorageLevel
import org.apache.spark.streaming.{Seconds, StreamingContext}

object FileWordCount {
  def main(args: Array[String]): Unit = {
    var sparkConf = new SparkConf().setMaster("local").setAppName("FileWordCount")

    val ssc = new StreamingContext(sparkConf, Seconds(5))

    val lines = ssc.textFileStream("file:////Users/walle/Documents/D2/testFile/")

    val result = lines.flatMap(_.split(" ")).map((_, 1)).reduceByKey(_ + _)

    result.print()

    ssc.start()

    ssc.awaitTermination()
  }
}

http://www.waitingfy.com/archives/4218

4218

Leave a Reply

Name and Email Address are required fields.
Your email will not be published or shared with third parties.