0
我有Scala中兩個陣列都用相同的數字映射在階多個陣列
val v = myGraph.vertices.collect.map(_._1)
其給出:
Array[org.apache.spark.graphx.VertexId] = Array(-7023794695707475841, -44591218498176864, 757355101589630892, 21619280952332745)
和另一
val w = myGraph.vertices.collect.map(_._2._2)
其給出:
Array[String] = Array(2, 3, 1, 2)
,我想創建一個使用
val z = v.map("{id:" + _ + "," + "group:" + "1" + "}").mkString(",")
這給出了一個字符串:
String = {id:-7023794695707475841,group:1},{id:-44591218498176864,group:1},{id:757355101589630892,group:1},{id:21619280952332745,group:1}
但現在不是「1」的硬編碼組,我想,而不是從數字地圖w陣列給:
String = {id:-7023794695707475841,group:2},{id:-44591218498176864,group:3},{id:757355101589630892,group:1},{id:21619280952332745,group:2}
我該如何做?
Slouc,感謝您的答覆快和工作:) –