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

    https://github.com/apache/spark/pull/12574#discussion_r60779700
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/recommendation/MatrixFactorizationModel.scala
 ---
    @@ -261,58 +261,93 @@ object MatrixFactorizationModel extends 
Loader[MatrixFactorizationModel] {
       }
     
       /**
    -   * Makes recommendations for all users (or products).
    -   * @param rank rank
    -   * @param srcFeatures src features to receive recommendations
    -   * @param dstFeatures dst features used to make recommendations
    -   * @param num number of recommendations for each record
    -   * @return an RDD of (srcId: Int, recommendations), where 
recommendations are stored as an array
    -   *         of (dstId, rating) pairs.
    +   * Makes recommendations for all users (or items).
    +   *
    +   * @param rank rank the dimension of the factor vectors
    +   * @param srcFactors src factor to receive recommendations
    +   * @param dstFactors dst factor used to make recommendations
    +   * @param num number of recommendations for each user (or item)
    +   * @return an RDD of (srcId, recommendations) pairs, where 
recommendations are stored as an array
    +   *         of (dstId, score) pairs.
        */
    -  private def recommendForAll(
    +  private[spark] def recommendForAll[T: ClassTag : Fractional](
           rank: Int,
    -      srcFeatures: RDD[(Int, Array[Double])],
    -      dstFeatures: RDD[(Int, Array[Double])],
    -      num: Int): RDD[(Int, Array[(Int, Double)])] = {
    -    val srcBlocks = blockify(rank, srcFeatures)
    -    val dstBlocks = blockify(rank, dstFeatures)
    +      srcFactors: RDD[(Int, Array[T])],
    +      dstFactors: RDD[(Int, Array[T])],
    +      num: Int): RDD[(Int, Array[(Int, T)])] = {
    +    val srcBlocks = blockify(rank, srcFactors)
    +    val dstBlocks = blockify(rank, dstFactors)
    +    val tag = implicitly[ClassTag[T]].runtimeClass
         val ratings = srcBlocks.cartesian(dstBlocks).flatMap {
           case ((srcIds, srcFactors), (dstIds, dstFactors)) =>
    --- End diff --
    
    For large inputs it's probably going to be more efficient to use 
`mllib.linalg.distributed.BlockMatrix`, which uses a custom partitioner. If 
BlockMatrix is *not* more efficient here, then BlockMatrix ought to have an 
alternate implementation of multiply for skinny matrices IMO.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to