Package org.apache.sysds.runtime.io
Class MatrixWriter
java.lang.Object
org.apache.sysds.runtime.io.MatrixWriter
- Direct Known Subclasses:
WriterBinaryBlock,WriterCompressed,WriterDelta,WriterHDF5,WriterMatrixMarket,WriterTextCell,WriterTextCSV,WriterTextLIBSVM
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic MatrixBlock[]createMatrixBlocksForReuse(long rlen, long clen, int blen, boolean sparse, long nonZeros) static MatrixBlockgetMatrixBlockForReuse(MatrixBlock[] blocks, int rows, int cols, int blen) voidsetForcedParallel(boolean par) abstract voidwriteEmptyMatrixToHDFS(String fname, long rlen, long clen, int blen) Writes a minimal entry to represent an empty matrix on hdfs.abstract longwriteMatrixFromStream(String fname, OOCStream<IndexedMatrixValue> stream, long rlen, long clen, int blen) Consumes an out-of-core stream of matrix blocks and writes them to the target output path.voidwriteMatrixToHDFS(MatrixBlock src, String fname, long rlen, long clen, int blen, long nnz) abstract voidwriteMatrixToHDFS(MatrixBlock src, String fname, long rlen, long clen, int blen, long nnz, boolean diag)
-
Constructor Details
-
MatrixWriter
public MatrixWriter()
-
-
Method Details
-
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
-
writeMatrixFromStream
public abstract long writeMatrixFromStream(String fname, OOCStream<IndexedMatrixValue> stream, long rlen, long clen, int blen) throws IOException Consumes an out-of-core stream of matrix blocks and writes them to the target output path. Implementations may choose single-file or multipart output depending on format and parallelism.- Parameters:
fname- The target output filenamestream- The OOC stream of matrix blocks to consumerlen- The total number of rows in the matrixclen- The total number of columns in the matrixblen- The block size- Throws:
IOException- if an I/O error occurs
-
setForcedParallel
public void setForcedParallel(boolean par) -
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 namerlen- number of rowsclen- number of columnsblen- 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)
-