我现在正试图从RDD[Edge[String]]
构建RDD[(Long,Long,String)]
我看过Edge
的src代码,它的参数为Edge(VertexId,VertexId,ED)
,所以我想如果我有RDD[(Long,Long,String)]
我可以将其转换为RDD[Edge[String]]
我的代码是
val c:RDD[(String, String)] = something
val s:RDD[(String, String)] = something
val edgeRDD: RDD[Edge[String]] = c
.join(s).map({
case (num: String, (src: String, dst: String))
=> (src.toLong, dst.toLong, expRelation)
}
)
但最后我收到了type mismatch
错误
[error] found : (Long, Long, String)
[error] required: org.apache.spark.graphx.Edge[String]
[error] => (src.toLong, dst.toLong, expRelation)
[error] ^
所以我想知道是否有办法直接从RDD[Edge[ED]]
构建RDD[(Long,Long,ED)]
答案 0 :(得分:0)
您的函数未返回Edge [String]。将返回类型更改为
Edge(src.toLong, dst.toLong, expRelation)
代码:
val c:RDD[(String, String)] = something
val s:RDD[(String, String)] = something
val edgeRDD: RDD[Edge[String]] = c
.join(s).map({
case (num: String, (src: String, dst: String))
=> Edge(src.toLong, dst.toLong, expRelation)
}
)