我刚开始学习 apache spark,想知道为什么这对我不起作用。
我正在运行 spark 2.1 并启动了一个主人和一个 worker (不是本地的)。这是我的代码:
object SimpleApp {
def main(args: Array[String]) {
val file = [FILELOCATION]
val conf = new SparkConf().setAppName("Simple Application")
val sc = new SparkContext(conf)
val textFile = sc.textFile(file)
val counts = textFile.flatMap(line => line.split(" "))
.map(word => (word.toLowerCase.toCharArray.toList.sorted.mkString, 1))
.reduceByKey(_ + _)
counts.map(println)
counts.foreach(println)
val countCollect = counts.collect()
sc.stop()
}
}
我似乎无法让工作节点在标准输出中打印出它们的内容。即使我将 master 和 worker 设置为本地,它似乎也不起作用。
我在这里理解错了吗?
最佳答案
如果你想在 executor 中打印一些东西,一个普通的 println 就可以了。这将在执行程序的标准输出中打印输出
关于scala - 星火集群 : How to print out the content of RDD on each worker node,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43906329/