Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/9916#discussion_r49251953
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/BlockMatrix.scala
---
@@ -332,18 +336,18 @@ class BlockMatrix @Since("1.3.0") (
if (rowsPerBlock == other.rowsPerBlock && colsPerBlock ==
other.colsPerBlock) {
val addedBlocks = blocks.cogroup(other.blocks, createPartitioner())
.map { case ((blockRowIndex, blockColIndex), (a, b)) =>
- if (a.size > 1 || b.size > 1) {
- throw new SparkException("There are multiple MatrixBlocks with
indices: " +
- s"($blockRowIndex, $blockColIndex). Please remove them.")
- }
- if (a.isEmpty) {
- new MatrixBlock((blockRowIndex, blockColIndex), b.head)
- } else if (b.isEmpty) {
- new MatrixBlock((blockRowIndex, blockColIndex), a.head)
- } else {
- val result = a.head.toBreeze + b.head.toBreeze
- new MatrixBlock((blockRowIndex, blockColIndex),
Matrices.fromBreeze(result))
- }
+ if (a.size > 1 || b.size > 1) {
+ throw new SparkException("There are multiple MatrixBlocks with
indices: " +
+ s"($blockRowIndex, $blockColIndex). Please remove them.")
+ }
+ if (a.isEmpty) {
+ new MatrixBlock((blockRowIndex, blockColIndex), b.head)
+ } else if (b.isEmpty) {
+ new MatrixBlock((blockRowIndex, blockColIndex), a.head)
--- End diff --
This and line 344 are incorrect. What if you write a-b but a has no block?
Then the resulting block will be "b" but should be "-b".
Before you fix this, I'd recommend improving the unit test to catch this
case & fail; then you can fix it.
---
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]