This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val streamingContext: StreamingContext = new StreamingContext(sparkContext, Seconds(20)) | |
| val lines: ReceiverInputDStream[String] = streamingContext.socketTextStream("localhost", 9999) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val split :RDD[String] = rdd.flatMap(_.split(" ")) | |
| val trim :RDD[String] = split.map(_.trim.toLowerCase) | |
| val stopwordsRemoved = trim.filter( x => !Set("and", "the", "is", "to", "she", "he").contains(x)) | |
| val assignOne = stopwordsRemoved.map((_, 1)) | |
| val counts = assignOne.reduceByKey(_ + _) |
OlderNewer