spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Localhost shell <universal.localh...@gmail.com>
Subject How to access objects declared and initialized outside the call() method of JavaRDD
Date Thu, 23 Oct 2014 07:46:06 GMT
Hey All,

I am unable to access objects declared and initialized outside the call()
method of JavaRDD.

In the below code snippet, call() method makes a fetch call to C* but since
javaSparkContext is defined outside the call method scope so compiler give
a compilation error.

stringRdd.foreach(new VoidFunction<String>() {
                @Override
                public void call(String str) throws Exception {
                    JavaRDD<String> vals =
javaFunctions(javaSparkContext).cassandraTable("schema", "table",
String.class)
                            .select("val");
                }
            });

In other languages I have used closure to do this but not able to achieve
the same here.

Can someone suggest how to achieve this in the current code context?


--Unilocal

Mime
View raw message