Package org.apache.sysds.runtime.io

## Class MatrixWriter

- java.lang.Object
- - org.apache.sysds.runtime.io.MatrixWriter

Direct Known Subclasses:
  `WriterBinaryBlock`, `WriterCompressed`, `WriterHDF5`, `WriterMatrixMarket`, `WriterTextCell`, `WriterTextCSV`, `WriterTextLIBSVM`

    public abstract class MatrixWriter
    extends Object

Base class for all format-specific matrix writers. Every writer is required to implement the basic write functionality but might provide additional custom functionality. Any non-default parameters (e.g., CSV read properties) should be passed into custom constructors. There is also a factory for creating format-specific writers.

### Constructor Summary

Constructors
`MatrixWriter()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`static MatrixBlock[]` `createMatrixBlocksForReuse​(long rlen, long clen, int blen, boolean sparse, long nonZeros)`
`static MatrixBlock` `getMatrixBlockForReuse​(MatrixBlock[] blocks, int rows, int cols, int blen)`
`abstract void` `writeEmptyMatrixToHDFS​(String fname, long rlen, long clen, int blen)` Writes a minimal entry to represent an empty matrix on hdfs.
`void` `writeMatrixToHDFS​(MatrixBlock src, String fname, long rlen, long clen, int blen, long nnz)`
`abstract void` `writeMatrixToHDFS​(MatrixBlock src, String fname, long rlen, long clen, int blen, long nnz, boolean diag)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### MatrixWriter

    public MatrixWriter()

### Method Detail

#### writeMatrixToHDFS

    public void writeMatrixToHDFS​(MatrixBlock src,
                                  String fname,
                                  long rlen,
                                  long clen,
                                  int blen,
                                  long nnz)
                           throws IOException

Throws:
  `IOException`

#### writeMatrixToHDFS

    public abstract void writeMatrixToHDFS​(MatrixBlock src,
                                           String fname,
                                           long rlen,
                                           long clen,
                                           int blen,
                                           long nnz,
                                           boolean diag)
                                    throws IOException

Throws:
  `IOException`

#### writeEmptyMatrixToHDFS

    public abstract void writeEmptyMatrixToHDFS​(String fname,
                                                long rlen,
                                                long clen,
                                                int blen)
                                         throws IOException

Writes a minimal entry to represent an empty matrix on hdfs.

Parameters:
  `fname` - file name
  `rlen` - number of rows
  `clen` - number of columns
  `blen` - number of rows/cols in block
Throws:
  `IOException` - if IOException occurs

#### createMatrixBlocksForReuse

    public static MatrixBlock[] createMatrixBlocksForReuse​(long rlen,
                                                           long clen,
                                                           int blen,
                                                           boolean sparse,
                                                           long nonZeros)

#### getMatrixBlockForReuse

    public static MatrixBlock getMatrixBlockForReuse​(MatrixBlock[] blocks,
                                                     int rows,
                                                     int cols,
                                                     int blen)