sc.textFile("/input/words.txt")
.flatMap(line => line.split(" "))
.map(word => (word, 1))
.reduceByKey((x, y) => x + y)
.collect
sc.textFile("/input/words.txt")
.flatMap(_.split(" "))
.map((_, 1))
.reduceByKey(_ + _)
.collect
sc.textFile("/input/words.txt")
.flatMap(line => line.split(" "))
.map(word => (word, 1))
.reduceByKey((x, y) => x + y)
.collect
sc.textFile("/input/words.txt")
.flatMap(_.split(" "))
.map((_, 1))
.reduceByKey(_ + _)
.collect
本文标题:Spark 简单的wordcount
本文链接:https://www.haomeiwen.com/subject/nxpskxtx.html
网友评论