Spart shell 运行 word count 示例

因为每个worker需要工作同一文件上, 所以需要通过hdfs来访问

sc.textFile("hdfs://hadoop-01:9000/aaa")
.flatMap(_.split(" "))
.map((_,1))
.reduceByKey(_+_)
.sortBy(_._2,false)
.collect
发布了188 篇原创文章 · 获赞 323 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_33709508/article/details/104164231