Skip to content

Instantly share code, notes, and snippets.

@blogscot
Created November 18, 2016 12:37
Show Gist options
  • Save blogscot/5f44a992017378c9852005d846a779b8 to your computer and use it in GitHub Desktop.
Save blogscot/5f44a992017378c9852005d846a779b8 to your computer and use it in GitHub Desktop.
The hello word for Apache Spark
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
object SimpleApp {
def main(args: Array[String]) {
val conf = new SparkConf().setAppName("Simple Application")
val sc = new SparkContext(conf)
sc.setLogLevel("WARN")
val letters = Array('a','b','c','b','c','c','d','e','f')
val myRDD = sc.parallelize(letters)
myRDD.map(letter => (letter, 1))
.reduceByKey(_+_)
.collect()
.foreach(println)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment