gpt4 book ai didi

java - 如何将列表对象转换为 JavaDStream Spark?

转载 作者:搜寻专家 更新时间:2023-11-01 02:38:29 25 4
gpt4 key购买 nike

我有下面的 List 对象:

List<Tuple2<Tuple3<String, Long, Object>, Tuple2<Long, Object[]>>> rddQueue =
Arrays.asList(tupleList);

如何将其转换为 JavaDStream Spark?提前致谢!

最佳答案

您可以使用 JavaStreamingContext 来做到这一点和一个 Queue<T> :

List<Tuple2<Tuple3<String, Long, Object>, Tuple2<Long, Object[]>>> 
list = Arrays.asList();

// Random batch time, for the sake of the example.
JavaStreamingContext jssc =
new JavaStreamingContext("local[*]", "TestApp", new Duration(4000));

Queue<JavaRDD<Tuple2<Tuple3<String, Long, Object>, Tuple2<Long, Object[]>>>> rddQueue =
new LinkedList<>();

rddQueue.add(jssc.sparkContext().parallelize(list));

JavaDStream<Tuple2<Tuple3<String, Long, Object>, Tuple2<Long, Object[]>>> dStream =
jssc.queueStream(rddQueue);

关于java - 如何将列表对象转换为 JavaDStream Spark?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40276224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com