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边的属性,什么是做到这一点的最好方法是什么?
非常感谢,这工作!并感谢您的解释。 –