We know that in spark there is a method rdd.collect which converts RDD to a list.
List f= rdd.collect(); String[] array = f.toArray(new String[f.si
Adding to Sean Owen and others solutions
You can use JavaSparkContext#parallelizePairs for List ofTuple
JavaSparkContext#parallelizePairs
List
Tuple
List> pairs = new ArrayList<>(); pairs.add(new Tuple2<>(0, 5)); pairs.add(new Tuple2<>(1, 3)); JavaSparkContext sc = new JavaSparkContext(); JavaPairRDD rdd = sc.parallelizePairs(pairs);