File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
mllib/src/main/scala/org/apache/spark/ml/recommendation Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -637,12 +637,19 @@ object ALS extends DefaultParamsReadable[ALS] with Logging {
637637 }
638638
639639 private def copyToTri (): Unit = {
640+ var i = 0
641+ var j = 0
640642 var ii = 0
641- for (i <- 0 until k)
642- for (j <- 0 to i) {
643- ata(ii) += ata2(i * k + j)
643+ while (i < k) {
644+ val temp = i * k
645+ j = 0
646+ while (j <= i) {
647+ ata(ii) += ata2(temp + j)
648+ j += 1
644649 ii += 1
645650 }
651+ i += 1
652+ }
646653 }
647654
648655 /** Adds an observation. */
@@ -1316,7 +1323,9 @@ object ALS extends DefaultParamsReadable[ALS] with Logging {
13161323 }
13171324 var i = srcPtrs(j)
13181325 var numExplicits = 0
1319- val doStack = if (srcPtrs(j + 1 ) - srcPtrs(j) > 10 ) true else false
1326+ // Stacking factors(vectors) in matrices to speed up the computation,
1327+ // when the number of factors and the rank is large enough.
1328+ val doStack = srcPtrs(j + 1 ) - srcPtrs(j) > 128 && rank > 128
13201329 val srcFactorBuffer = mutable.ArrayBuilder .make[Double ]
13211330 val bBuffer = mutable.ArrayBuilder .make[Double ]
13221331 while (i < srcPtrs(j + 1 )) {
You can’t perform that action at this time.
0 commit comments