【发布时间】:2014-10-26 04:00:51
【问题描述】:
我有两个 RDD:points 和 pointsWithinEps。它们的内容如下图所示:
向量代表x, y坐标。 pointsWithinEps 代表两点和它们之间的距离。我想循环所有points,并且对于每个点,仅将pointsWithinEps 中的元素过滤为x(第一个)坐标。所以对于第一点,它将给出来自pointsWithinEps 的[0] 和[1] 向量。我有以下代码:
for (i <- 0 until points.count.toInt) {
val p = points.take(i + 1).drop(i)
val currentPointNeighbours = pointsWithinEps.filter {
case ((x, y), distance) =>
x == p
}
currentPointNeighbours.foreach(println)
println("----")
}
它不能正常工作。代码有什么问题?
【问题讨论】:
标签: scala foreach filter apache-spark