Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.42 KB | None | 0 0
  1. object SparkWordCount {
  2.   def main(args: Array[String]) {
  3.     val time = System.currentTimeMillis()
  4.     val logFile = "README.md"
  5.     val conf = new SparkConf()
  6.     val sc = new SparkContext(conf)
  7.  
  8.     val file = sc.textFile(logFile, 10)
  9.     var pairs = file.flatMap(line => line.trim().split(" ")).map(word => (word, 1))
  10.     var counts = pairs.reduceByKey(_ + _)
  11.     val result = counts.collect().foreach(println)
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement