Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/10839#discussion_r56062757
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/BlockMatrix.scala
---
@@ -268,8 +268,26 @@ class BlockMatrix @Since("1.3.0") (
def toIndexedRowMatrix(): IndexedRowMatrix = {
require(numCols() < Int.MaxValue, "The number of columns must be
within the integer range. " +
s"numCols: ${numCols()}")
- // TODO: This implementation may be optimized
- toCoordinateMatrix().toIndexedRowMatrix()
+
+ val rows = blocks.map(block => (block._1._1, (block._1._2, block._2)))
+ .groupByKey()
--- End diff --
This assumes that a partition can hold an entire block row, which is not
always valid. I would suggest the following:
* for each block, break the matrix block into rows and then emit (rowIdx,
row). You can map the matrix block to a breeze matrix, and then call rows.
* call groupByKey and then concat breeze vectors
This could be a more scalable implementation.
---
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]