Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object sparkExample {
- def main(arg: Array[String]) {
- val conf = new SparkConf().setAppName("SparkExample").setMaster("local[*]")
- val sc = new SparkContext(conf)
- val lines = sc.textFile("data.txt")
- val words = lines.flatMap(l => l.split(" "))
- val pairs = splitLines.map(w => (w,1))
- val wordCount = pairs.reduceByKey((a,b) => a + b)
- wordCount.collect().foreach(println)
- }
- }
Add Comment
Please, Sign In to add comment