Skip to content

Commit 752b685

Browse files
committed
address review comments
1 parent 3b0f71c commit 752b685

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mllib/src/main/scala/org/apache/spark/ml/clustering/PowerIterationClustering.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class PowerIterationClustering private[clustering] (
180180
case Row(id: Long, nbr: Vector, weight: Vector) =>
181181
require(nbr.size == weight.size,
182182
"The length of neighbor list must be equal to the the length of the weight list.")
183-
val ids = Array.fill(nbr.size)(id)
184-
for (i <- 0 until ids.size) yield (ids(i), nbr(i).toLong, weight(i))}
183+
nbr.toArray.toIterator.zip(weight.toArray.toIterator)
184+
.map(x => (id, x._1.toLong, x._2.toLong))}
185185
val algorithm = new MLlibPowerIterationClustering()
186186
.setK($(k))
187187
.setInitializationMode($(initMode))

0 commit comments

Comments
 (0)