Created
November 18, 2016 12:37
-
-
Save blogscot/5f44a992017378c9852005d846a779b8 to your computer and use it in GitHub Desktop.
The hello word for Apache Spark
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
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