在 Gelly 中,我正在尝试制作一个称为 Temporal edge 的特殊 Edge,为了使这更容易,我制作了一个名为 Temporaledgev3 的类:
public class TemporalEdgev3<K, V> extends Edge<K, Tuple3<V,Integer,Integer>> {
/*
Creates new temporaledge with only null values
*/
public TemporalEdgev3() {}
/*
* Constructor to make a temporal edge version 2, has 5 input values but makes a
* typle 3 which is compatible with Gelly
* */
public TemporalEdgev3(K src, K trg, V val, Integer start, Integer end) {
this.f0 = src;
this.f1 = trg;
this.f2 = new Tuple3<V,Integer,Integer>(val,start,end);
}
现在我正在尝试将这些边添加到 Flink DataSet 中,以便它可以在图中使用,但我似乎无法弄清楚如何。但是,当我使用具有相同构造函数的 Edge 类时,它可以工作。
这是代码,最后一行给出了错误
// a temporal set created with Flink, now we need to make it into a temporal set into gelly
DataSet<Tuple5<Long,Long, Double,Integer, Integer>> temporalset = env.readCsvFile("./datasets/testdata")
.fieldDelimiter(",") // node IDs are separated by spaces
.ignoreComments("%") // comments start with "%"
.types(Long.class,Long.class,Double.class,Integer.class,Integer.class); // read the node IDs as Longs
DataSet<TemporalEdgev3<Long,Double>> edgeset3 = temporalset.map(new MapFunction<Tuple5<Long, Long, Double, Integer, Integer>, TemporalEdgev3<Long, Double>>() {
@Override
public TemporalEdgev3<Long, Double> map(Tuple5<Long, Long, Double, Integer, Integer> value) throws Exception {
return new TemporalEdgev3<Long, Double>(value.f0,value.f1,value.f2,value.f3,value.f4);
}
});
DataSet<Edge<Long,Tuple3<Double,Integer,Integer>>> edgeset4 = temporalset.map(new MapFunction<Tuple5<Long, Long, Double, Integer, Integer>, Edge<Long, Tuple3<Double, Integer, Integer>>>() {
@Override
public Edge<Long, Tuple3<Double, Integer, Integer>> map(Tuple5<Long, Long, Double, Integer, Integer> value) throws Exception {
return new Edge<Long, Tuple3<Double, Integer, Integer>>(value.f0,value.f1, new Tuple3<Double, Integer, Integer>(value.f2,value.f3,value.f4));
}
});
Graph<Long, NullValue, Tuple3<Double,Integer,Integer>> temporalgraph = Graph.fromDataSet(edgeset4,env);
Graph<Long,NullValue, Tuple3<Double,Integer,Integer>> temporalgraph2 = Graph.fromDataSet(edgeset3,env);
错误:错误的第一个参数类型。找到:'org.apache.flink.api.java.DataSet>',需要:'org.apache.flink.api.java.DataSet>' 少...
fromDataSet
(org.apache.flink.api.java.DataSet<org.apache.flink.graph.Edge<K,EV>>,
ExecutionEnvironment)
in Graph cannot be applied
to
(org.apache.flink.api.java.DataSet<flink.gelly.school.TemporalEdgev3<java.lang.Long,java.lang.Double>>,
ExecutionEnvironment)
reason: no instance(s) of type variable(s) EV, K exist so that TemporalEdgev3<Long, Double> conforms to Edge<K, EV>
也许我只是不知道如何使用泛型类型