Class DirectByteBufferOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public final class DirectByteBufferOutputStream
    extends OutputStream
    This class is a customized output stream implementation backed by ByteBuffer, which utilizes off heap memory when writing the data via MemoryPoolAssigner. Deletion of dataList, which is the memory this outputstream holds, occurs when the corresponding block is deleted.
    • Method Detail

      • write

        public void write​(int b)
                   throws IOException
        Writes the specified byte to this output stream.
        Specified by:
        write in class OutputStream
        Parameters:
        b - the byte to be written.
        Throws:
        IOException
      • write

        public void write​(byte[] b)
                   throws IOException
        Writes b.length bytes from the specified byte array to this output stream.
        Overrides:
        write in class OutputStream
        Parameters:
        b - the byte to be written.
        Throws:
        IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws IOException
        Writes len bytes from the specified byte array starting at offset off to this output stream.
        Overrides:
        write in class OutputStream
        Parameters:
        b - the data.
        off - the start offset in the data.
        len - the number of bytes to write.
        Throws:
        IOException
      • getMemoryChunkList

        public List<MemoryChunk> getMemoryChunkList()
        Returns the list of MemoryChunks that contains the written data. List of flipped and duplicated MemoryChunks are returned, which has independent position and limit, to reduce erroneous data read/write. This function has to be called when intended to read from the start of the list of MemoryChunks, not for additional write.
        Returns:
        the LinkedList of MemoryChunks.
      • size

        public int size()
        Returns the size of the data written in this output stream.
        Returns:
        the size of the data