Permalink
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (19 sloc) 614 Bytes
package org.peelframework.wordcount.spark
import org.apache.spark.{SparkConf, SparkContext}
/** A `WordCount` workload job for Spark. */
object SparkWC {
def main(args: Array[String]) {
if (args.length != 2) {
Console.err.println("Usage: <jar> inputPath outputPath")
System.exit(-1)
}
val inputPath = args(0)
val outputPath = args(1)
val spark = new SparkContext(new SparkConf().setAppName("peel-wordcount-spark"))
spark.textFile(inputPath)
.flatMap(_.toLowerCase.split("\\W+"))
.map((_, 1))
.reduceByKey(_ + _)
.saveAsTextFile(outputPath)
}
}