JavaRDD对象的创建失败 [英] Creation of JavaRDD object has failed
本文介绍了JavaRDD对象的创建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这块code的:
ArrayList<Row> list = new ArrayList<Row>();
Row testRow = RowFactory.create(true, 101.0, "string");
list.add(testRow);
JavaRDD<Row> testRDD = JavaSparkContext.parallelize(list);
在此code,我有以下错误消息的最后一行:
In the last line of this code I have the following error message:
不能使静态参考非静态方法
prallelize(列表&LT;行>)。从类型JavaSparkContext
Cannot make a static reference to the non-static method prallelize(List < Row > ) from the type JavaSparkContext.
我怎样才能提高我的code和创建从我的列表中JavaRDD对象(实际上应该有多个行对象)。目前,我不明白,这我code的一部分是静态的。
How can I improve my code and create a JavaRDD object from my list (which actually should have multiple Rows objects). Currently I don't understand which part of my code is static.
推荐答案
您只需要实例JavaSparkContext。
You just have to instantiate JavaSparkContext.
SparkConf conf = new SparkConf();
conf.setAppName("YOUR APP");
//other config like conf.setMaster("YOUR MASTER");
JavaSparkContext ctx = new JavaSparkContext(conf);
//and then
JavaRDD<Row> testRDD = ctx.parallelize(list);
这篇关于JavaRDD对象的创建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文