Convert a DStream to JavaDStream

我与影子孤独终老i 提交于 2019-12-22 18:19:10

问题


I know we have an option for RDD:

JavaRDD<String> javaRDD = coreRdd.toJavaRDD();`

is it possible to convert Dstream to JavaDStream?


回答1:


Yes, you can use the static JavaDStream<T>.fromDStream:

JavaDStream<String> javaDStream = 
   JavaDStream$.MODULE$.fromDStream(dStream,
                                    scala.reflect.ClassTag$.MODULE$.apply(String.class))

Another option would be to use the class constructor, which takes an existing DStream:

JavaDStream<String> javaDStream = 
   new JavaDStream<String>(dStream, scala.reflect.ClassTag$.MODULE$.apply(String.class))


来源:https://stackoverflow.com/questions/38410768/convert-a-dstream-to-javadstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!