WordCount in Spark
WordCount program is like basic hello world program when it comes to Big data world. Below is program to achieve wordCount in Spark with very few lines of code.
[code lang=”scala”]val inputlines = sc.textfile("/users/guest/read.txt")
val words = inputlines.flatMap(line=>line.split(" "))
val wMap = words.map(word => (word,1))
val wOutput = wMap.reduceByKey(_ + _)