小编Avi*_*yam的帖子

value <不是AnyVal的成员

我一直在scala中编写代码来找到最短的路径.这是我找到Shortest-Path的代码.但是我在下面的代码中遇到错误

if ( (kv1._1 + kv1._2 )< (kv2._1 + kv2._2)) kv1 else kv2 
Run Code Online (Sandbox Code Playgroud)

错误是

value < is not a member of AnyVal
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

 val inputRDD = sc.textFile(args(0)).map { line =>
  val a = line.split(",")
  (a(0).toLong, (a(1).toLong, a(2).toLong))
}
var distanceRDD = inputRDD.flatMap(x => {
  val pair1 = if (x._1 == 0) (x._1, 0) else (x._1, Long.MaxValue)
  val pair2 = if (x._2._1 == 0) (x._2._1, 0) else (x._2._1, Long.MaxValue)

  List(pair1, pair2)
}).distinct()

for ( index <- 1 to 4 ) { …
Run Code Online (Sandbox Code Playgroud)

scala shortest-path apache-spark

2
推荐指数
1
解决办法
1988
查看次数

标签 统计

apache-spark ×1

scala ×1

shortest-path ×1