Package org.apache.sysds.api.mlcontext
Class Matrix
- java.lang.Object
- 
- org.apache.sysds.api.mlcontext.Matrix
 
- 
 public class Matrix extends Object Matrix encapsulates a SystemDS matrix. It allows for easy conversion to various other formats, such as RDDs, JavaRDDs, DataFrames, and double[][]s. After script execution, it offers a convenient format for obtaining SystemDS matrix data in Scala tuples.
- 
- 
Constructor SummaryConstructors Constructor Description Matrix(org.apache.spark.api.java.JavaPairRDD<MatrixIndexes,MatrixBlock> binaryBlocks, MatrixMetadata matrixMetadata)Create a Matrix, specifying the SystemDS binary-block matrix and its metadata.Matrix(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataFrame)Convert a Spark DataFrame to a SystemDS binary-block representation.Matrix(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataFrame, long numRows, long numCols)Convert a Spark DataFrame to a SystemDS binary-block representation, specifying the number of rows and columns.Matrix(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataFrame, MatrixMetadata matrixMetadata)Convert a Spark DataFrame to a SystemDS binary-block representation.Matrix(MatrixObject matrixObject, SparkExecutionContext sparkExecutionContext)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description MatrixMetadatagetMatrixMetadata()Obtain the matrix metadatabooleanhasBinaryBlocks()Whether or not this matrix contains data as binary blocksbooleanhasMatrixObject()Whether or not this matrix contains data as a MatrixObjectdouble[][]to2DDoubleArray()Obtain the matrix as a two-dimensional double arrayorg.apache.spark.api.java.JavaPairRDD<MatrixIndexes,MatrixBlock>toBinaryBlocks()Obtain the matrix as aJavaPairRDD<MatrixIndexes, MatrixBlock>org.apache.spark.sql.Dataset<org.apache.spark.sql.Row>toDF()Obtain the matrix as aDataFrameof doubles with an ID columnorg.apache.spark.sql.Dataset<org.apache.spark.sql.Row>toDFDoubleNoIDColumn()Obtain the matrix as aDataFrameof doubles with no ID columnorg.apache.spark.sql.Dataset<org.apache.spark.sql.Row>toDFDoubleWithIDColumn()Obtain the matrix as aDataFrameof doubles with an ID columnorg.apache.spark.sql.Dataset<org.apache.spark.sql.Row>toDFVectorNoIDColumn()Obtain the matrix as aDataFrameof vectors with no ID columnorg.apache.spark.sql.Dataset<org.apache.spark.sql.Row>toDFVectorWithIDColumn()Obtain the matrix as aDataFrameof vectors with an ID columnorg.apache.spark.api.java.JavaRDD<String>toJavaRDDStringCSV()Obtain the matrix as aJavaRDD<String>in CSV formatorg.apache.spark.api.java.JavaRDD<String>toJavaRDDStringIJV()Obtain the matrix as aJavaRDD<String>in IJV formatMatrixBlocktoMatrixBlock()Obtain the matrix as aMatrixBlockMatrixObjecttoMatrixObject()Obtain the matrix as a SystemDS MatrixObject.org.apache.spark.rdd.RDD<String>toRDDStringCSV()Obtain the matrix as aRDD<String>in CSV formatorg.apache.spark.rdd.RDD<String>toRDDStringIJV()Obtain the matrix as aRDD<String>in IJV formatStringtoString()IfMatrixObjectis available, outputMatrixObject.toString().
 
- 
- 
- 
Constructor Detail- 
Matrixpublic Matrix(MatrixObject matrixObject, SparkExecutionContext sparkExecutionContext) 
 - 
Matrixpublic Matrix(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataFrame, MatrixMetadata matrixMetadata)Convert a Spark DataFrame to a SystemDS binary-block representation.- Parameters:
- dataFrame- the Spark DataFrame
- matrixMetadata- matrix metadata, such as number of rows and columns
 
 - 
Matrixpublic Matrix(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataFrame, long numRows, long numCols)Convert a Spark DataFrame to a SystemDS binary-block representation, specifying the number of rows and columns.- Parameters:
- dataFrame- the Spark DataFrame
- numRows- the number of rows
- numCols- the number of columns
 
 - 
Matrixpublic Matrix(org.apache.spark.api.java.JavaPairRDD<MatrixIndexes,MatrixBlock> binaryBlocks, MatrixMetadata matrixMetadata) Create a Matrix, specifying the SystemDS binary-block matrix and its metadata.- Parameters:
- binaryBlocks- the- JavaPairRDD<MatrixIndexes, MatrixBlock>matrix
- matrixMetadata- matrix metadata, such as number of rows and columns
 
 - 
Matrixpublic Matrix(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> dataFrame) Convert a Spark DataFrame to a SystemDS binary-block representation.- Parameters:
- dataFrame- the Spark DataFrame
 
 
- 
 - 
Method Detail- 
toMatrixObjectpublic MatrixObject toMatrixObject() Obtain the matrix as a SystemDS MatrixObject.- Returns:
- the matrix as a SystemDS MatrixObject
 
 - 
to2DDoubleArraypublic double[][] to2DDoubleArray() Obtain the matrix as a two-dimensional double array- Returns:
- the matrix as a two-dimensional double array
 
 - 
toJavaRDDStringIJVpublic org.apache.spark.api.java.JavaRDD<String> toJavaRDDStringIJV() Obtain the matrix as aJavaRDD<String>in IJV format- Returns:
- the matrix as a JavaRDD<String>in IJV format
 
 - 
toJavaRDDStringCSVpublic org.apache.spark.api.java.JavaRDD<String> toJavaRDDStringCSV() Obtain the matrix as aJavaRDD<String>in CSV format- Returns:
- the matrix as a JavaRDD<String>in CSV format
 
 - 
toRDDStringCSVpublic org.apache.spark.rdd.RDD<String> toRDDStringCSV() Obtain the matrix as aRDD<String>in CSV format- Returns:
- the matrix as a RDD<String>in CSV format
 
 - 
toRDDStringIJVpublic org.apache.spark.rdd.RDD<String> toRDDStringIJV() Obtain the matrix as aRDD<String>in IJV format- Returns:
- the matrix as a RDD<String>in IJV format
 
 - 
toDFpublic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> toDF() Obtain the matrix as aDataFrameof doubles with an ID column- Returns:
- the matrix as a DataFrameof doubles with an ID column
 
 - 
toDFDoubleWithIDColumnpublic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> toDFDoubleWithIDColumn() Obtain the matrix as aDataFrameof doubles with an ID column- Returns:
- the matrix as a DataFrameof doubles with an ID column
 
 - 
toDFDoubleNoIDColumnpublic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> toDFDoubleNoIDColumn() Obtain the matrix as aDataFrameof doubles with no ID column- Returns:
- the matrix as a DataFrameof doubles with no ID column
 
 - 
toDFVectorWithIDColumnpublic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> toDFVectorWithIDColumn() Obtain the matrix as aDataFrameof vectors with an ID column- Returns:
- the matrix as a DataFrameof vectors with an ID column
 
 - 
toDFVectorNoIDColumnpublic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> toDFVectorNoIDColumn() Obtain the matrix as aDataFrameof vectors with no ID column- Returns:
- the matrix as a DataFrameof vectors with no ID column
 
 - 
toBinaryBlockspublic org.apache.spark.api.java.JavaPairRDD<MatrixIndexes,MatrixBlock> toBinaryBlocks() Obtain the matrix as aJavaPairRDD<MatrixIndexes, MatrixBlock>- Returns:
- the matrix as a JavaPairRDD<MatrixIndexes, MatrixBlock>
 
 - 
toMatrixBlockpublic MatrixBlock toMatrixBlock() Obtain the matrix as aMatrixBlock- Returns:
- the matrix as a MatrixBlock
 
 - 
getMatrixMetadatapublic MatrixMetadata getMatrixMetadata() Obtain the matrix metadata- Returns:
- the matrix metadata
 
 - 
toStringpublic String toString() IfMatrixObjectis available, outputMatrixObject.toString(). IfMatrixObjectis not available butMatrixMetadatais available, outputMatrixMetadata.toString(). Otherwise outputObject.toString().
 - 
hasBinaryBlockspublic boolean hasBinaryBlocks() Whether or not this matrix contains data as binary blocks- Returns:
- trueif data as binary blocks are present,- falseotherwise.
 
 - 
hasMatrixObjectpublic boolean hasMatrixObject() Whether or not this matrix contains data as a MatrixObject- Returns:
- trueif data as binary blocks are present,- falseotherwise.
 
 
- 
 
-