3
讓我們說我有一個邊緣屬性爲double值的圖形,我想找到我的圖形的最大邊緣權重。如果我這樣做:在Spark GraphX中尋找最大邊緣權重
val max = sc.accumulator(0.0) //max holds the maximum edge weight
g.edges.distinct.collect.foreach{ e => if (e.attr > max.value) max.value
= e.attr }
我想問有多少工作在主服務器完成,多少對 執行人,因爲我知道,收集()方法帶來了整個RDD到 大師?平行度是否會發生?有沒有更好的方法來找到最大邊緣重量的 ?
注:
g.edges.distinct.foreach{ e => if (e.attr > max.value) max.value =
e.attr } // does not work without the collect() method.
//I use an accumulator because I want to use the max edge weight later
如果我想申請一些平均函數有兩個圖之間的相同srcId和dstId邊的屬性,什麼是做到這一點的最好方法是什麼?
非常感謝,這工作!並感謝您的解釋。 –