我正在尝试使用sun-codemodel创建以下内容。
JavaRDD<Activitydaily> activityBatchDailyRDDs =
activityBatchDailyFunction.cassandraTable("test", "tbl")
.map(new Function<CassandraRow, Activitydaily>() {
public Activitydaily call(CassandraRow v1) throws Exception {
return new Activitydaily();
}
});
以下是我的代码。但它是完整的。我不知道如何完成它。
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);
以下是我目前的输出。
JavaRDD<Activitydaily> ActivitydailyRDD =
ActivitydailyFunction.cassandraTable("demo", "activitydaily")
.map(new Function<CassandraRow, Activitydaily>());
答案 0 :(得分:0)
这里真正的问题是:如何定义匿名内部类。
要定义anonymouse内部类,只需使用//This will search for all div with Id starts with "Held" and it will loop through them
$("div[id^='Held']").each(function(){
var divName = this.id;
var uniqueId = divName.replace('Held', '');
if ( isItemExists(uniqueId, data.onHold, 'interactionId') ){
this.remove();
}
});
// This function will find a value inside a
function isItemExists(needle, haystack, elementKey){
return $.grep(haystack, function(item){
return item.elementKey== needle;
});
};
实例上的anonymousClass()
方法:
Jcm
然后在JDefinedClass anonymousFunctionClass = cm.anonymousClass(function.narrow(cassandraRow, activityBatchDailyRealTimeBean));
JMethod callMethod = anonymousFunctionClass.method(JMod.PUBLIC, Activitydaily.class, "call");
callMethod._throws(Exception.class);
JVar v1Param = callMethod.param(CassandraRow.class, "v1");
callMethod.body()._return(JExpr._new(cm.ref(Activitydaily.class)));
电话中使用它:
JExpr._new()
结果如下:
JClass cassandraConnector = cm.directClass("com.datastax.spark.connector.cql.CassandraConnector");
// Anonymous inner class declaration:
JDefinedClass anonymousFunctionClass = cm.anonymousClass(function.narrow(cassandraRow, activityBatchDailyRealTimeBean));
JMethod callMethod = anonymousFunctionClass.method(JMod.PUBLIC, Activitydaily.class, "call");
callMethod._throws(Exception.class);
JVar v1Param = callMethod.param(CassandraRow.class, "v1");
callMethod.body()._return(JExpr._new(cm.ref(Activitydaily.class)));
JExpression functionExpression = JExpr._new(anonymousFunctionClass);
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);