Created
February 2, 2016 06:11
-
-
Save malaikannan/8b42e94d6edd0aa3d58b 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
/** | |
* Created by malai on 2/1/16. | |
*/ | |
import org.apache.spark.SparkConf | |
import org.apache.spark.SparkContext | |
import org.apache.spark.SparkContext._ | |
object WordCount { | |
def main(args:Array[String]) : Unit = { | |
val logFile = "/home/malai/spark-1.6.0/README.md" | |
val conf = new SparkConf().setAppName("Simple Application") | |
val sc = new SparkContext(conf) | |
val input = sc.textFile(logFile) | |
val words = input.flatMap(line => line.split(" ")) | |
val counts = words.map(word => (word,1)).reduceByKey{case(x,y) => x + y} | |
counts.saveAsTextFile("/home/malai/spark-1.6.0/README_log1.md") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment