Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Convert List Object to JavaDStream Spark?

i have List object bellow:

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

how can convert its to JavaDStream Spark ? thank advance !

like image 725
Too You Avatar asked Oct 27 '16 04:10

Too You


1 Answers

You can do that using the JavaStreamingContext and a 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);
like image 110
Yuval Itzchakov Avatar answered Oct 23 '22 09:10

Yuval Itzchakov