[SPARK-10757] [MLlib] Java friendly constructor for distributed matrices #9159
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch allows java developers to construct BlockMatrix and RowMatrix more naturally.
Take BlockMatrix as an example, the type of 'blocks' in current constructor is RDD[((Int, Int), Matrix)], while more precisely it should be RDD[((Int, Int), T<:Matrix)]. This could cause some problem. If we add a Java-friendly constructor
and then construct a BlockMatrix with RDD[(Int, Int), DenseMatrix], the complier will complain a conflict, like:
On the other hand, BlockMatrix should hide the underlying implementation of sub-matrix, no matter it is dense or sparse. Thus, a class level covariant for Matrix is improper. That's why I add a companion object method to construct BlockMatrix/RowMatrix
For IndexedRowMatrix/CoordinateMatrix, since the RDD parameters for them are really simple and contain no type inheritance, I don't see necessity to add additional Java friendly apis for those two. Or do we need them to let java users construct IndexedRowMatrix/CoordinateMatrix in the same way as what they do with BlockMatrix/RowMatrix?