Class ByteArrayOutputStream

java.lang.Object
java.io.OutputStream
org.apache.hadoop.hbase.io.ByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, ByteBufferWriter

@Private public class ByteArrayOutputStream extends OutputStream implements ByteBufferWriter
Our own implementation of ByteArrayOutputStream where all methods are NOT synchronized and supports writing ByteBuffer directly to it.
  • Field Details

  • Constructor Details

  • Method Details

    • write

      public void write(ByteBuffer b, int off, int len)
      Description copied from interface: ByteBufferWriter
      Writes len bytes from the specified ByteBuffer starting at offset off
      Specified by:
      write in interface ByteBufferWriter
      Parameters:
      b - the data.
      off - the start offset in the data.
      len - the number of bytes to write.
    • writeInt

      public void writeInt(int i)
      Description copied from interface: ByteBufferWriter
      Writes an int to the underlying output stream as four bytes, high byte first.
      Specified by:
      writeInt in interface ByteBufferWriter
      Parameters:
      i - the int to write
    • write

      public void write(int b)
      Specified by:
      write in class OutputStream
    • write

      public void write(byte[] b, int off, int len)
      Overrides:
      write in class OutputStream
    • checkSizeAndGrow

      private void checkSizeAndGrow(int extra)
    • reset

      public void reset()
      Resets the pos field of this byte array output stream to zero. The output stream can be used again.
    • toByteArray

      public byte[] toByteArray()
      Copies the content of this Stream into a new byte array.
      Returns:
      the contents of this output stream, as new byte array.
    • toByteBuff

      public void toByteBuff(ByteBuff buff)
    • getBuffer

      public byte[] getBuffer()
      Returns the underlying array where the data gets accumulated
    • size

      public int size()
      Returns The current size of the buffer.