Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object SparkWordCount {
- def main(args: Array[String]) {
- val time = System.currentTimeMillis()
- val logFile = "README.md"
- val conf = new SparkConf()
- val sc = new SparkContext(conf)
- val file = sc.textFile(logFile, 10)
- var pairs = file.flatMap(line => line.trim().split(" ")).map(word => (word, 1))
- var counts = pairs.reduceByKey(_ + _)
- val result = counts.collect().foreach(println)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement