I am trying to create the following using sun-codemodel.
JavaRDD<Activitydaily> activityBatchDailyRDDs =
activityBatchDailyFunction.cassandraTable("test", "tbl")
.map(new Function<CassandraRow, Activitydaily>() {
public Activitydaily call(CassandraRow v1) throws Exception {
return new Activitydaily();
}
});
Following is my code. But it is in complete. I don't know how to complete it.
JClass cassandraConnector = cm.directClass("com.datastax.spark.connector.cql.CassandraConnector");
JExpression functionExpression = JExpr._new(
function.narrow(cassandraRow, activityBatchDailyRealTimeBean));
JExpression javaRDDAssignmentExpression = JExpr
.invoke(JExpr.ref(className + "Function"), "cassandraTable")
.arg(schema).arg(table);
javaRDDAssignmentExpression = javaRDDAssignmentExpression.invoke("map")
.arg(functionExpression);
executerBlock.decl(javaRDD.narrow(activityBatchDailyRealTimeBean),
className + "RDD", javaRDDAssignmentExpression);
The below is my current output.
JavaRDD<Activitydaily> ActivitydailyRDD =
ActivitydailyFunction.cassandraTable("demo", "activitydaily")
.map(new Function<CassandraRow, Activitydaily>());
The real question here is: how does one define an anonymous inner class.
To Define an anonymouse inner class, you simply using the
anonymousClass()
method on theJcm
instance:Then use it in your
JExpr._new()
call:The result of this looks like the following: