0

I have an array of object like this

 edges: Array[Array[(Long, Long, String)]] = Array(Array((-209215114,197853780,Investor), (-209215114,-322475625,Investor), ...

and i want to convert it to an array of Edge to pass to a Graph builder. Here is what i am using:

 val eRDD: RDD[Edge[(VertexId, VertexId, String)]] = edges.map(x => Edge(x(0), x(1), x(2)))

I am getting the following error:

<console>:107: error: type mismatch;
found   : (Long, Long, String)
required: org.apache.spark.graphx.VertexId
(which expands to)  Long
   val eRDD: RDD[Edge[(VertexId, VertexId, String)]] = edges.map(x => Edge(x(0), x(1), x(2)))
Eoin Lane
  • 641
  • 2
  • 6
  • 22

1 Answers1

2

Your type definition is wrong. Either do:

val eRDD: RDD[Edge[String]] = edges.map(x => Edge(x(0), x(1), x(2)))

or just do:

val eRDD = edges.map(x => Edge(x(0), x(1), x(2)))

And let Scala infer the type for you.

David Griffin
  • 13,677
  • 5
  • 47
  • 65