Created
November 27, 2018 16:37
-
-
Save mveeneman/8785b169ea59cbf737570e2ebcf37c4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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