Balaji Reddy Balaji Reddy - 4 months ago 57
Java Question

Convert a DStream to JavaDStream

I know we have an option for

RDD
:

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


is it possible to convert Dstream to JavaDStream?

Answer

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))