Skip to content

Commit

Permalink
Reindent estimateCost's declaration and make it return Seqs.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmyklebu committed Apr 29, 2014
1 parent 8b21e6d commit 2ab7a5d
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,12 @@ object ALS {
* @param productPartitioner partitioner for partitioning products
*/
@DeveloperApi
def estimateCost(ratings: RDD[Rating], rank: Int, userPartitioner: Partitioner,
productPartitioner: Partitioner):
(Map[Int, IterationCost], Map[Int, IterationCost]) = {
def estimateCost(
ratings: RDD[Rating],
rank: Int,
userPartitioner: Partitioner,
productPartitioner: Partitioner
): (Seq[IterationCost], Seq[IterationCost]) = {
// user partition -> set of products
val utalk = ratings.mapPartitions(x => {
val ht = new mutable.HashSet[(Int, Int)]()
Expand Down Expand Up @@ -823,7 +826,8 @@ object ALS {
// We do two rank*rank outer products per rating and one Cholesky factorisation per user and
// per product.

(userAnswer.toMap, productAnswer.toMap)
( userAnswer.toArray.sortBy(x => x._1).map(x => x._2),
productAnswer.toArray.sortBy(x => x._1).map(x => x._2))
}

private class ALSRegistrator extends KryoRegistrator {
Expand Down

0 comments on commit 2ab7a5d

Please sign in to comment.