Home > other >  Spark Graphx how to make a picture contains attribute types different side
Spark Graphx how to make a picture contains attribute types different side

Time:10-13

In a diagram vertices may be said in a variety of different business objects, each object, therefore, may have different attributes, to put in one picture, which is put in a set of vertices RDD, use polymorphic can solve, RDD [T] or RDD [(S, T)] this pattern, S and T in the base class declaration, store different subclasses, subclass each have each attribute,

But if you want to let the side can also different attributes, is not easy, because the (S, T) the tuples can polymorphism, use (Long, BaseClass) can represent (Long, ttf_subclass), but the Edge [BaseClass] and Edge [ttf_subclass] is not same,,, so the last line of the following code will compile error, prompt RDD [] in the element type is not consistent,

Everyone is how to solve the similar demand?

 
Case class VertexAttr (XXXX) extends the Serializable {
}
The class VA (XXXXX) extends EdgeAttr (XXXXX) {
}
The class VB (XXXXX) extends EdgeAttr (XXXXX) {
}

Case class EdgeAttr (XXXXX) extends the Serializable {
}
The class EA (XXXXX) extends EdgeAttr (XXXX) {
}

The class EB (XXXXX) extends EdgeAttr (XXXX) {
}


Val vertexArray=Array (
(1 l, new VA (" XXXX ")),
(2 l, new VA (" XXXX ")),
(3 l, new VB (" XXXX "))
)
Val edgeArray=Array (
Edge (1 l, 2 l, new EA (" XXXX ")),
Edge (1 l, 3 l, new EB (" XXXX ")),
The Edge (2 l, 3 l, new EB (" XXXX "))
)

//structure vertexRDD and edgeRDD
Val vertexRDD: RDD. [(Long, VertexAttr)]=sc parallelize (vertexArray)
Val edgeRDD: RDD [Edge [EdgeAttr]]=sc. Parallelize (edgeArray)

CodePudding user response:

Excuse me, would you please tell me the problem you solve it? There is a problem, if the node the creation, then to filter on node should
how to match?
  • Related