Package org.apache.sysds.runtime.util

## Class FastBufferedDataOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - java.io.FilterOutputStream
    - - org.apache.sysds.runtime.util.FastBufferedDataOutputStream

All Implemented Interfaces:
  `Closeable`, `DataOutput`, `Flushable`, `AutoCloseable`, `MatrixBlockDataOutput`

    public class FastBufferedDataOutputStream
    extends FilterOutputStream
    implements DataOutput, MatrixBlockDataOutput

This buffered output stream is essentially a merged version of BufferedOutputStream and DataOutputStream, wrt SystemDS requirements. Micro-benchmarks showed a 25% performance improvement for local write binary block due to the following advantages: - 1) unsynchronized buffered output stream (not required in SystemDS since single writer) - 2) single output buffer (avoid two-level buffers of individual streams) - 3) specific support for writing double arrays in a blockwise fashion

### Constructor Summary

Constructors
`FastBufferedDataOutputStream​(OutputStream out)`
`FastBufferedDataOutputStream​(OutputStream out, int size)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()`
`void` `flush()`
`void` `write​(byte[] b, int off, int len)`
`void` `write​(int b)`
`void` `writeBoolean​(boolean v)`
`void` `writeByte​(int v)`
`void` `writeBytes​(String s)`
`void` `writeChar​(int v)`
`void` `writeChars​(String s)`
`void` `writeDouble​(double v)`
`void` `writeDoubleArray​(int len, double[] varr)` Writes the double array of a dense block to the data output.
`void` `writeFloat​(float v)`
`void` `writeInt​(int v)`
`void` `writeLong​(long v)`
`void` `writeShort​(int v)`
`void` `writeSparseRows​(int rlen, SparseBlock rows)` Writes the sparse rows array of a sparse block to the data output.
`void` `writeUTF​(String s)`

### Methods inherited from class java.io.FilterOutputStream

`write`

### Methods inherited from class java.io.OutputStream

`nullOutputStream`

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

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

### Methods inherited from interface java.io.DataOutput

`write`

### Constructor Detail

#### FastBufferedDataOutputStream

    public FastBufferedDataOutputStream​(OutputStream out)

#### FastBufferedDataOutputStream

    public FastBufferedDataOutputStream​(OutputStream out,
                                        int size)

### Method Detail

#### write

    public void write​(int b)
               throws IOException

Specified by:
  `write` in interface `DataOutput`
Overrides:
  `write` in class `FilterOutputStream`
Throws:
  `IOException`

#### write

    public void write​(byte[] b,
                      int off,
                      int len)
               throws IOException

Specified by:
  `write` in interface `DataOutput`
Overrides:
  `write` in class `FilterOutputStream`
Throws:
  `IOException`

#### flush

    public void flush()
               throws IOException

Specified by:
  `flush` in interface `Flushable`
Overrides:
  `flush` in class `FilterOutputStream`
Throws:
  `IOException`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `FilterOutputStream`
Throws:
  `IOException`

#### writeBoolean

    public void writeBoolean​(boolean v)
                      throws IOException

Specified by:
  `writeBoolean` in interface `DataOutput`
Throws:
  `IOException`

#### writeInt

    public void writeInt​(int v)
                  throws IOException

Specified by:
  `writeInt` in interface `DataOutput`
Throws:
  `IOException`

#### writeLong

    public void writeLong​(long v)
                   throws IOException

Specified by:
  `writeLong` in interface `DataOutput`
Throws:
  `IOException`

#### writeDouble

    public void writeDouble​(double v)
                     throws IOException

Specified by:
  `writeDouble` in interface `DataOutput`
Throws:
  `IOException`

#### writeByte

    public void writeByte​(int v)
                   throws IOException

Specified by:
  `writeByte` in interface `DataOutput`
Throws:
  `IOException`

#### writeShort

    public void writeShort​(int v)
                    throws IOException

Specified by:
  `writeShort` in interface `DataOutput`
Throws:
  `IOException`

#### writeBytes

    public void writeBytes​(String s)
                    throws IOException

Specified by:
  `writeBytes` in interface `DataOutput`
Throws:
  `IOException`

#### writeChar

    public void writeChar​(int v)
                   throws IOException

Specified by:
  `writeChar` in interface `DataOutput`
Throws:
  `IOException`

#### writeChars

    public void writeChars​(String s)
                    throws IOException

Specified by:
  `writeChars` in interface `DataOutput`
Throws:
  `IOException`

#### writeFloat

    public void writeFloat​(float v)
                    throws IOException

Specified by:
  `writeFloat` in interface `DataOutput`
Throws:
  `IOException`

#### writeUTF

    public void writeUTF​(String s)
                  throws IOException

Specified by:
  `writeUTF` in interface `DataOutput`
Throws:
  `IOException`

#### writeDoubleArray

    public void writeDoubleArray​(int len,
                                 double[] varr)
                          throws IOException

Description copied from interface: `MatrixBlockDataOutput`
Writes the double array of a dense block to the data output.

Specified by:
  `writeDoubleArray` in interface `MatrixBlockDataOutput`
Parameters:
  `len` - ?
  `varr` - ?
Throws:
  `IOException` - if IOException occurs

#### writeSparseRows

    public void writeSparseRows​(int rlen,
                                SparseBlock rows)
                         throws IOException

Description copied from interface: `MatrixBlockDataOutput`
Writes the sparse rows array of a sparse block to the data output.

Specified by:
  `writeSparseRows` in interface `MatrixBlockDataOutput`
Parameters:
  `rlen` - ?
  `rows` - sparse block
Throws:
  `IOException` - if IOException occurs