Spark运行第一个Scala程序WordCount
- 2019 年 12 月 26 日
- 筆記
1、前置条件安装
hadoop:
https://blog.csdn.net/jxq0816/article/details/78736449
scala:
https://www.runoob.com/scala/scala-install.html 2、Idea安装Scala插件

3、代码
object ScalaWordCount { def main(args: Array[String]): Unit = { var lines = List("hello scala", "hello world","hello java") //切分并压平 val words = lines.flatMap(_.split(" ")) // 把每个单词生成一个一个pair(key, 1) val tuples = words.map((_, 1)) //以key进行分组 第一个_代表元组,第二个_1 代表key(单词) val gro