2016-04-29 17 views
0

數組我有對象的這樣對於GraphX我如何對象的數組轉換爲邊

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

一個數組,我想將其轉換爲邊的一個數組來傳遞給圖形生成器。這裏是我使用的是什麼:

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

我收到以下錯誤:

<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))) 

回答

2

你的類型定義是錯誤的。無論是做:

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

或只是做:

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

而讓斯卡拉推斷類型適合你。

+0

優秀的大衛,謝謝 –

相關問題