【发布时间】:2017-06-10 03:48:32
【问题描述】:
我正在尝试使用 apache spark/scala 找到单词数量最多的行。我在 spark-shell 中运行程序。
当我使用以下代码时,我得到了正确的输出:
scala> file1.map(line => line.split(" ").size).reduce((a, b) => if (a > b) a else b)
但是当我尝试使用以下代码收集结果时出现错误:
scala> file1.map(line => line.split(" ").size).reduce((a, b) => if (a > b) a else b).collect()
<console>:30: error: value collect is not a member of Int
file1.map(line => line.split(" ").size).reduce((a, b) => if (a > b) a else b).collect()
为什么我在使用collect() 操作时会出错?
【问题讨论】:
标签: scala apache-spark