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

Reply via email to