Skip to content

Instantly share code, notes, and snippets.

@Swalloow
Created March 25, 2017 14:28
Show Gist options
  • Save Swalloow/ddc125f58b2b2ca4815444557d769bdb to your computer and use it in GitHub Desktop.
Save Swalloow/ddc125f58b2b2ca4815444557d769bdb to your computer and use it in GitHub Desktop.
WordCount with Scala
val file = spark.textFile("hdfs://...")
val counts = file.flatMap(line => line.split(" "))
.map(word => (word, 1))
.reduceByKey(_ + _)
counts.saveAsTextFile("hdfs://...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment