Skip to content

Commit

Permalink
Use Ints instead of Longs in the shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
rezazadeh committed Aug 31, 2014
1 parent 0f12ade commit 75a0b51
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class RowMatrix(
val sg = math.sqrt(gamma) // sqrt(gamma) used many times

val sims = rows.flatMap { row =>
val buf = new ListBuffer[((Long, Long), Double)]()
val buf = new ListBuffer[((Int, Int), Double)]()
row.toBreeze.activeIterator.foreach {
case (_, 0.0) => // Skip explicit zero elements.
case (i, iVal) =>
Expand All @@ -452,7 +452,7 @@ class RowMatrix(
case (_, 0.0) => // Skip explicit zero elements.
case (j, jVal) =>
if (Math.random < sg / colMags(j)) {
val contrib = ((i.toLong, j.toLong), (iVal * jVal) /
val contrib = ((i, j), (iVal * jVal) /
(math.min(sg, colMags(i)) * math.min(sg, colMags(j))))
buf += contrib
}
Expand All @@ -461,7 +461,7 @@ class RowMatrix(
}
buf
}.reduceByKey(_ + _).map { case ((i, j), sim) =>
MatrixEntry(i, j, sim)
MatrixEntry(i.toLong, j.toLong, sim)
}
new CoordinateMatrix(sims, numCols(), numCols())
}
Expand Down

0 comments on commit 75a0b51

Please sign in to comment.