Guest User

Untitled

a guest
Dec 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. object sparkExample {
  2. def main(arg: Array[String]) {
  3. val conf = new SparkConf().setAppName("SparkExample").setMaster("local[*]")
  4. val sc = new SparkContext(conf)
  5.  
  6. val lines = sc.textFile("data.txt")
  7. val words = lines.flatMap(l => l.split(" "))
  8. val pairs = splitLines.map(w => (w,1))
  9. val wordCount = pairs.reduceByKey((a,b) => a + b)
  10.  
  11. wordCount.collect().foreach(println)
  12. }
  13. }
Add Comment
Please, Sign In to add comment