Github user danielyli commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17793#discussion_r113894646
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala 
---
    @@ -791,32 +813,43 @@ object ALS extends DefaultParamsReadable[ALS] with 
Logging {
           checkpointInterval: Int = 10,
           seed: Long = 0L)(
           implicit ord: Ordering[ID]): (RDD[(ID, Array[Float])], RDD[(ID, 
Array[Float])]) = {
    +
         require(!ratings.isEmpty(), s"No ratings available from $ratings")
         require(intermediateRDDStorageLevel != StorageLevel.NONE,
           "ALS is not designed to run without persisting intermediate RDDs.")
    +
         val sc = ratings.sparkContext
    +
    +    // Precompute the rating dependencies of each partition
         val userPart = new ALSPartitioner(numUserBlocks)
         val itemPart = new ALSPartitioner(numItemBlocks)
    -    val userLocalIndexEncoder = new 
LocalIndexEncoder(userPart.numPartitions)
    -    val itemLocalIndexEncoder = new 
LocalIndexEncoder(itemPart.numPartitions)
    -    val solver = if (nonnegative) new NNLSSolver else new CholeskySolver
         val blockRatings = partitionRatings(ratings, userPart, itemPart)
           .persist(intermediateRDDStorageLevel)
         val (userInBlocks, userOutBlocks) =
           makeBlocks("user", blockRatings, userPart, itemPart, 
intermediateRDDStorageLevel)
    -    // materialize blockRatings and user blocks
    -    userOutBlocks.count()
    +    userOutBlocks.count()    // materialize blockRatings and user blocks
         val swappedBlockRatings = blockRatings.map {
           case ((userBlockId, itemBlockId), RatingBlock(userIds, itemIds, 
localRatings)) =>
             ((itemBlockId, userBlockId), RatingBlock(itemIds, userIds, 
localRatings))
         }
         val (itemInBlocks, itemOutBlocks) =
           makeBlocks("item", swappedBlockRatings, itemPart, userPart, 
intermediateRDDStorageLevel)
    -    // materialize item blocks
    -    itemOutBlocks.count()
    +    itemOutBlocks.count()    // materialize item blocks
    +
    +    // Encoders for storing each user/item's partition ID and index within 
its partition using a
    --- End diff --
    
    I moved the code because otherwise the comment on L823 (`// Precompute the 
rating dependencies of each partition`) would reference the 
`LocalIndexEncoder`s and the `solver`.  Agreed that otherwise it would be 
unnecessary to move.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to