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

    https://github.com/apache/spark/pull/14068#discussion_r70181291
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/BlockMatrix.scala
 ---
    @@ -426,16 +426,19 @@ class BlockMatrix @Since("1.3.0") (
           partitioner: GridPartitioner): (BlockDestinations, 
BlockDestinations) = {
         val leftMatrix = blockInfo.keys.collect() // blockInfo should already 
be cached
         val rightMatrix = other.blocks.keys.collect()
    +
    +    val rightCounterpartsHelper = 
rightMatrix.groupBy(_._1).mapValues(_.map(_._2))
         val leftDestinations = leftMatrix.map { case (rowIndex, colIndex) =>
    -      val rightCounterparts = rightMatrix.filter(_._1 == colIndex)
    -      val partitions = rightCounterparts.map(b => 
partitioner.getPartition((rowIndex, b._2)))
    -      ((rowIndex, colIndex), partitions.toSet)
    +      ((rowIndex, colIndex), rightCounterpartsHelper.getOrElse(colIndex, 
Array()).map(b =>
    --- End diff --
    
    nit: for readability could you assign this to a variable instead of 
inlining it?
    In addition, for multi-line expressions
    ```scala
    .map { b =>
      blah
    }
    ```
    is more preferred


---
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