以下问题类似:Spark Streaming with Twitter - No output streams registered, so nothing to execute然而我认为在 51
中使用 wordCounts.print()
我实际上输出了一些结果 .
基本代码:
ssc.start()
ssc.awaitTermination()
val lines = messages.map(_._2)
val words = lines.flatMap(_.split(" "))
val wordCounts = words.map(x => (x, 1L)).reduceByKey(_ + _)
wordCounts.print()
或者我在这里误解了什么?要跟进:https://github.com/dataplayground/playground/blob/master/app/actors/DirectStreamingActor.scala
2 回答
应该是你的代码中的最后一个 .
来自http://spark.apache.org/docs/latest/streaming-programming-guide.html#output-operations-on-dstreams
所以's actually because you didn'在
start()
时执行任何输出操作 . 当您将start()
和awaitTermination()
移动到代码中的最后一个位置时,您执行了输出操作,因此它可以正常工作 .