【发布时间】:2017-12-12 08:38:44
【问题描述】:
我正在尝试根据 Spark 图中的入度对顶点列表进行排序(使用 Scala)
// Sort Ascending - both the 2 below yeild same results
gGraph.inDegrees.collect.sortBy(_._2).take(10)
gGraph.inDegrees.collect.sortWith(_._2 < _._2).take(10)
// Sort Decending
gGraph.inDegrees.collect.sortWith(_._2 > _._2).take(10)
gGraph.inDegrees.collect.sortBy(_._2, ascending=false).take(10) //Doesnt Work!!
我希望sortBy(_._2, ascending=false) 的结果与上面提到的sortWith(_._2>_._2) 相同。但得到以下错误。感谢您对此的任何想法。谢谢!
scala> gGraph.inDegrees.collect.sortBy(_.2, ascending=false).take(10) :55: 错误: 方法 sortBy 的参数太多: (f: ((org.apache.spark.graphx.VertexId, Int)) => B)(隐式排序: scala.math.Ordering[B])Array[(org.apache.spark.graphx.VertexId, Int)] gGraph.inDegrees.collect.sortBy(._2, ascending=false).take(10)
【问题讨论】:
标签: scala apache-spark spark-graphx