任何人请帮助我如何从现有的 RDD 创建 DStream。 我的代码是:
JavaSparkContext ctx = new JavaSparkContext(conf);
JavaRDD<String> rddd = ctx.parallelize(arraylist);
现在我需要使用这些 rddd 作为 JavaStreamingContext 的输入。
最佳答案
试一试queueStream API.
RDD队列作为一个Stream,每一个插入队列的RDD在DStream中都会被当作一批数据,像流一样处理。
public <T> InputDStream<T> queueStream(scala.collection.mutable.Queue<RDD<T>> queue,
boolean oneAtATime,
scala.reflect.ClassTag<T> evidence$15)
Create an input stream from a queue of RDDs. In each batch, it will process either one or all of the RDDs returned by the queue.
NOTE: Arbitrary RDDs can be added to queueStream, there is no way to recover data of those RDDs, so queueStream doesn't support checkpointing.
关于java - 来自现有 RDD 的 Spark Streaming,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35088171/