import org.apache.spark.sql.SparkSession object SparkWordCount extends App { val spark = SparkSession.builder .master("local[*]") .appName("Spark Word Count") .getOrCreate() val lines = spark.sparkContext.parallelize( Seq("There are two principle objectives for this course.", "First, to introduce the fundamental concepts necessary for the design and use of a database.", "Second, to provide practical experience in applying these concepts using commercial Introduction to High Performance Computing.")) val counts = lines .flatMap(line => line.split(" ")) .map(word => (word, 1)) .reduceByKey(_ + _) counts.foreach(println) spark.stop() }