textFileStream example

Shown in the following is a simple example of Spark Streaming using textFileStream. In this example, we create a StreamingContext from the spark-shell SparkContext (sc) and an interval of 10 seconds. This starts the textFileStream, which monitors the directory named streamfiles and processes any new file found in the directory. In this example, we are simply printing the number of elements in the RDD:

scala> import org.apache.spark._
scala> import org.apache.spark.streaming._

scala> val ssc = new StreamingContext(sc, Seconds(10))
scala> val filestream = ssc.textFileStream("streamfiles")
scala> filestream.foreachRDD(rdd => {println(rdd.count())})
scala> ssc.start
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.204.8