Skip to content

Instantly share code, notes, and snippets.

@mveeneman
Created November 27, 2018 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mveeneman/8785b169ea59cbf737570e2ebcf37c4e to your computer and use it in GitHub Desktop.
Save mveeneman/8785b169ea59cbf737570e2ebcf37c4e to your computer and use it in GitHub Desktop.
/* SimpleApp.scala */
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
object WordCountApp {
def main(args: Array[String]) {
val conf = new SparkConf().setAppName("WordCount Application")
val sc = new SparkContext(conf)
val textFile = sc.textFile("file:///mnt/Data/textfile.txt")
val counts = textFile.flatMap(line => line.split(" ")).map(word => (word,1)).reduceByKey(_ + _)
counts.saveAsTextFile("file:///tmp/Output.txt")
sc.stop()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment