如何列表转换为JavaRDD [英] How to convert List to JavaRDD
本文介绍了如何列表转换为JavaRDD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们知道,在火花有它转换为RDD列表的方法rdd.collect。
We know that in spark there is a method rdd.collect which converts RDD to a list.
List<String> f= rdd.collect();
String[] array = f.toArray(new String[f.size()]);
我想在我的项目正好相反做。我有字符串的ArrayList,我要转换为JavaRDD。我找了这个解决方案相当长的一段时间,但还没有找到答案。任何人都可以请帮我在这里?
I am trying to do exactly opposite in my project. I have an ArrayList of String which I want to convert to JavaRDD. I am looking for this solution for quite some time but have not found the answer. Can anybody please help me out here?
推荐答案
您正在寻找的<$c$c>JavaSparkContext.parallelize(List)$c$c>和类似的。这就像Scala的API中
You're looking for JavaSparkContext.parallelize(List)
and similar. This is just like in the Scala API.
这篇关于如何列表转换为JavaRDD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文