Skip to content

Instantly share code, notes, and snippets.

@dedunumax
Created May 14, 2016 17:09
Show Gist options
  • Save dedunumax/749a390d97fd20bf0991402c0b29d7a2 to your computer and use it in GitHub Desktop.
Save dedunumax/749a390d97fd20bf0991402c0b29d7a2 to your computer and use it in GitHub Desktop.
package org.dedunu.datascience.sample
import org.apache.spark.{SparkContext, SparkConf}
object Driver {
def main(args: Array[String]): Unit = {
val sparkConf = new SparkConf().setAppName("Sample Job Name")
val sparkContext = new SparkContext(sparkConf)
val textFile = sparkContext.textFile("file://" + args(0) + "/*")
val counts = textFile.flatMap(line => line.split(" "))
.map(word => (word, 1))
.reduceByKey(_ + _)
counts.saveAsTextFile("file://" + args(1))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment