Class UnsynchronizedBuffer.Writer

    • Constructor Detail

      • Writer

        public Writer()
        Creates a new writer.
      • Writer

        public Writer​(int initialCapacity)
        Creates a new writer.
        Parameters:
        initialCapacity - initial byte capacity
    • Method Detail

      • add

        public void add​(byte[] bytes,
                        int off,
                        int length)
        Adds bytes to this writer's buffer.
        Parameters:
        bytes - byte array
        off - offset into array to start copying bytes
        length - number of bytes to add
        Throws:
        IndexOutOfBoundsException - if off or length are invalid
      • add

        public void add​(boolean b)
        Adds a Boolean value to this writer's buffer.
        Parameters:
        b - Boolean value
      • toArray

        public byte[] toArray()
        Gets (a copy of) the contents of this writer's buffer.
        Returns:
        byte buffer contents
      • toByteBuffer

        public ByteBuffer toByteBuffer()
        Gets a ByteBuffer wrapped around this writer's buffer.
        Returns:
        byte buffer
      • writeVInt

        public void writeVInt​(int i)
        Adds an integer value to this writer's buffer. The integer is encoded as a variable-length list of bytes. See writeVLong(long) for a description of the encoding.
        Parameters:
        i - integer value
      • writeVLong

        public void writeVLong​(long i)
        Adds a long value to this writer's buffer. The long is encoded as a variable-length list of bytes. For a description of the encoding scheme, see WritableUtils.writeVLong() in the Hadoop API. [link]
        Parameters:
        i - long value
      • size

        public int size()