object Test3 {
System.setProperty("hadoop.home.dir","d://software/hadoop-2.9.2")
def main(args: Array[String]): Unit = {
val conf = new SparkConf().setMaster("local[2]").setAppName("sort")
val sc = new SparkContext(conf)
sc.textFile("D:\\大数据课件\\在线计算\\spark文档\\spark课件\\core\\data\\words.txt")
.flatMap(line => line.split(" "))
.filter(word => word.startsWith("spark"))
.map(word => (word,1))
.reduceByKey((x,y) => x+y)
.foreach(println)
}
}