Failed to create JavaRDD object

I have this piece of code:

ArrayList<Row> list = new ArrayList<Row>(); Row testRow = RowFactory.create(true, 101.0, "string"); list.add(testRow); JavaRDD<Row> testRDD = JavaSparkContext.parallelize(list); 

The following error message appears on the last line of this code:

It is not possible to make a static reference to the non-static method prallelize (List <Row>) of type JavaSparkContext.

How can I improve my code and create a JavaRDD object from my list (which should have multiple Rows). Currently, I do not understand what part of my code is static.

-2
java apache-spark
source share
1 answer

You just need to create an instance of 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); 
+1
source share

All Articles