Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/4279#discussion_r23827449
--- 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)
--- End diff --
Use `blockInfo`. This should be
~~~
blockInfo.countByKey().values.foreach { dup =>
if (dup > 1) {
throw SparkException("...")
}
}
~~~
---
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]