Skip to content

Instantly share code, notes, and snippets.

@mmafrar
Created April 23, 2025 23:25
Show Gist options
  • Save mmafrar/655e5c51e229956dfa9eb413e92a3377 to your computer and use it in GitHub Desktop.
Save mmafrar/655e5c51e229956dfa9eb413e92a3377 to your computer and use it in GitHub Desktop.
Big Data Processing - Case Study 2 (Spark)
val input_file = sc. textFile("/Users/mmafrar/WordCount/input_file.txt")
input_file.collect
val word = input_file.flatMap(line => line.split(" "))
word.collect
val mapdata = word. map (word => (word, 1))
val reducedata = mapdata. reduceByKey (_+_)
reducedata.collect
reducedata.saveAsTextFile ("/Users/mmafrar/WordCount/output_folder")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment