GitHub user javelinjs opened a pull request:

    https://github.com/apache/spark/pull/9159

    [SPARK-10757] [MLlib] Java friendly constructor for distributed matrices

    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
    
    ```{scala}
    def this(blocks: JavaRDD[((Integer, Integer), Matrix)],
        rowsPerBlock: Int,
        colsPerBlock: Int)
    ```
    and then construct a BlockMatrix with RDD[(Int, Int), DenseMatrix], the 
complier will complain a conflict, like:
    
    ```
    method constructor BlockMatrix with alternatives:
    (blocks: org.apache.spark.api.java.JavaRDD[((Integer, Integer), 
org.apache.spark.mllib.linalg.Matrix)],rowsPerBlock: Int,colsPerBlock: 
Int)org.apache.spark.mllib.linalg.distributed.BlockMatrix <and>
    (blocks: org.apache.spark.rdd.RDD[((Int, Int), 
org.apache.spark.mllib.linalg.Matrix)],rowsPerBlock: Int,colsPerBlock: 
Int)org.apache.spark.mllib.linalg.distributed.BlockMatrix
    cannot be applied to (org.apache.spark.rdd.RDD[((Int, Int), 
org.apache.spark.mllib.linalg.DenseMatrix)], Int, Int)
    ```
    
    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?

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/javelinjs/spark-1 
i10757-java-friendly-dist-matrices

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/9159.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #9159
    
----
commit 9de727bde64513cc3b8c17acb5fddfcdb2e7537d
Author: Yizhi Liu <[email protected]>
Date:   2015-10-18T07:42:42Z

    [SPARK-10757]Java friendly constructor for distributed matrices

commit 9b3a675569889f94be5cde28e1f1b899cef07d74
Author: Yizhi Liu <[email protected]>
Date:   2015-10-18T12:11:49Z

    [SPARK-10757] [MLlib] Java friendly constructor for distributed matrices

commit 8dbd4c5e4418324f329e26403239337c70e04804
Author: Yizhi Liu <[email protected]>
Date:   2015-10-18T12:15:16Z

    [SPARK-10757] [MLlib] Java friendly constructor for distributed matrices

----


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