Created
July 25, 2016 07:18
-
-
Save solidpple/ec1095fa1bfd24151acb2d0acb1dfe9d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import org.apache.spark.SparkConf | |
import org.apache.spark.SparkContext | |
import org.apache.spark.SparkContext._ | |
object WordCount { | |
def main(args: Array[String]) { | |
val conf = new SparkConf().setMaster("local").setAppName("Word Count") | |
val sc = new SparkContext(conf) | |
val input = sc.textFile("/home/starbucks/spark-1.6.1-bin-hadoop2.6/README.md") | |
val words = input.flatMap(line => line.split(" ")) | |
val counts = words.map(word => (word, 1)).reduceByKey{case (x, y) => x + y} | |
println("Word Count Scala Project") | |
counts.saveAsTextFile("/home/starbucks/spark-1.6.1-bin-hadoop2.6/projects/WordCount/outputs/wordcount") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment