我在运行spark app时出现以下错误:
Caused by: java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to [I
不,我没有创建一个名为I或[I.]的班级。它有点难以谷歌。有谁知道这意味着什么?
答案 0 :(得分:2)
这意味着map = []
point1back = {}
point1fwd = {}
point1back.update = {'nextHop':point1Fwd, 'direction':1, 'distance':0}
point1fwd.update = {'nextHop':point1Fwd, 'direction':3, 'distance':160}
map.append(point1back)
map.append(point1fwd)
。
Array[Int]
输出:
object Main extends App {
println(classOf[Array[Int]])
}
请参阅Class.getName
的Java文档。
答案 1 :(得分:1)
你可能有这样的事情:
def retrieveArray(): Seq[Int] = Array(1)
retrieveArray().asInstanceOf[Array[Int]]
这是失败的,因为当Array[Int]
转换为Seq[Int]
时,它变为WrappedArray[Int]
,其类型与Array[Int]
不同
retrieveArray().toArray
会进行转化