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

    https://github.com/apache/spark/pull/4279#discussion_r23827456
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/BlockMatrix.scala
 ---
    @@ -172,6 +172,64 @@ class BlockMatrix(
         assert(cols <= nCols, s"The number of columns $cols is more than 
claimed $nCols.")
       }
     
    +  def validate: Unit = {
    +    logDebug("Validating BlockMatrix...")
    +    // check if the matrix is larger than the claimed dimensions
    +    try {
    +      estimateDim()
    +      logDebug("BlockMatrix dimensions are okay...")
    +    } catch {
    +      case exc: AssertionError => throw new SparkException(s"$exc\nPlease 
instantiate a " +
    +        s"new BlockMatrix with the correct dimensions.")
    +      case e: Exception =>
    +        throw new 
SparkException(s"${e.getMessage}\n${e.getStackTraceString}")
    +    }
    +    // Check if there are multiple MatrixBlocks with the same index.
    +    val indexCounts = blocks.countByKey().filter(p => p._2 > 1)
    +    if (indexCounts.size > 50) {
    --- End diff --
    
    I don't understand this part. It is hard to guess what went wrong if there 
are more than 50 duplicates. I would rather leave it to users to find out. The 
code in my previous comment should be sufficient.


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