Class HeapNettyBuffer

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear the buffer
      void discardSomeReadBytes()
      Discard the bytes available to be read.
      byte[] getArray()
      Gets the byte array used by this buffer
      io.grpc.netty.shaded.io.netty.buffer.ByteBuf getBuffer()
      Gets the netty buffer
      void increaseBufferSize​(int newBufferSize)
      Increase the buffer size to a new size provided
      boolean isReadable()
      Check if the buffer has some bytes to read
      int maxCapacity()
      Gets the maximum capacity of the buffer
      int readableBytes()
      Get the number of bytes available to be read.
      boolean readBoolean()
      Get a boolean from the byte buffer
      boolean[] readBooleans​(int size)
      Get an array of booleans.
      byte readByte()
      Get a byte from the byte buffer
      byte[] readByteArray()
      Get a byte array from the byte buffer
      byte[][] readByteArrays​(int size)
      Get an array of byte arrays.
      void readBytes​(byte[] values)
      Get an array of bytes into the variable provided.
      byte[] readBytes​(int size)
      Get an array of bytes.
      char readChar()
      Get a char from the byte buffer
      char[] readChars​(int size)
      Get an array of chars.
      double readDouble()
      Get a double from the byte buffer
      double[] readDoubles​(int size)
      Get an array of doubles.
      int readerIndex()
      Get the index in buffer of the reader pointer
      float readFloat()
      Get a float from the byte buffer
      float[] readFloats​(int size)
      Get an array of floats.
      int readInt()
      Get an integer from the byte buffer
      int[] readInts​(int size)
      Get an array of integers from the byte buffer
      long readLong()
      Get a long from the byte buffer
      long[] readLongs​(int size)
      Get an array of longs.
      short readShort()
      Get a short from the byte buffer
      short[] readShorts​(int size)
      Get an array of shorts.
      String readString()
      Get a string from the byte buffer
      String[] readStrings​(int size)
      Get an array of strings.
      int readVLQInt()
      Get a variable length integer from the byte buffer.
      void release()
      Release the buffer
      void rewind()
      Rewind the buffer.
      void setBuffer​(io.grpc.netty.shaded.io.netty.buffer.ByteBuf byteBuf)
      Sets the netty buffer
      void setReaderIndex​(int index)
      Sets the reader index to the position with index provided
      void setWriterIndex​(int index)
      Sets the writer index to the position with index provided
      void wrapBytes​(byte[] newBuffer)
      Wrap bytes to avoid copying them.
      void writeBoolean​(boolean value)
      Put a boolean into the byte buffer.
      void writeBooleans​(boolean[] values)
      Put an array of booleans into the byte buffer.
      void writeByte​(byte value)
      Put a byte into the byte buffer.
      void writeByteArray​(byte[] value)
      Put a byte array into the byte buffer.
      void writeByteArrays​(byte[][] values)
      Put an array of byte arrays into the byte buffer.
      void writeBytes​(byte[] values)
      Put an array of bytes into the byte buffer.
      void writeBytes​(DataClayByteBuffer binBuffer)
      Copy all bytes from the buffer provided
      void writeBytes​(io.grpc.netty.shaded.io.netty.buffer.ByteBuf byteBuf)
      Write bytes in byte buffer.
      void writeChar​(char value)
      Put a char into the byte buffer.
      void writeChars​(char[] values)
      Put an array of chars into the byte buffer.
      void writeDouble​(double value)
      Put a double into the byte buffer.
      void writeDoubles​(double[] values)
      Put an array of doubles into the byte buffer.
      void writeFloat​(float value)
      Put a float into the byte buffer.
      void writeFloats​(float[] values)
      Put an array of floats into the byte buffer.
      void writeInt​(int value)
      Put an integer into the byte buffer.
      void writeInts​(int[] values)
      Put an array of integers into the byte buffer
      void writeLong​(long value)
      Put a long into the byte buffer.
      void writeLongs​(long[] values)
      Put an array of longs into the byte buffer.
      int writerIndex()
      Get the index in buffer of the writer pointer
      void writeShort​(short value)
      Put a short into the byte buffer.
      void writeShorts​(short[] values)
      Put an array of shorts into the byte buffer.
      void writeString​(String value)
      Put a string into the byte buffer.
      void writeStrings​(String[] values)
      Put an array of strings into the byte buffer.
      void writeVLQInt​(int value)
      Put a variable length integer into the byte buffer.
    • Constructor Detail

      • HeapNettyBuffer

        public HeapNettyBuffer​(byte[] newBuffer)
        Constructor used for decodification
        Parameters:
        newBuffer - The byte array to deserialize
      • HeapNettyBuffer

        public HeapNettyBuffer()
        Constructor used for codification
      • HeapNettyBuffer

        public HeapNettyBuffer​(io.grpc.netty.shaded.io.netty.buffer.ByteBuf data)
        Constructor
        Parameters:
        data - ByteBuf containing data
      • HeapNettyBuffer

        public HeapNettyBuffer​(ByteBuffer data)
        Constructor
        Parameters:
        data - ByteBuffer containing data
    • Method Detail

      • wrapBytes

        public void wrapBytes​(byte[] newBuffer)
        Description copied from interface: DataClayByteBuffer
        Wrap bytes to avoid copying them.
        Specified by:
        wrapBytes in interface DataClayByteBuffer
        Parameters:
        newBuffer - The byte array to deserialize
      • isReadable

        public boolean isReadable()
        Description copied from interface: DataClayByteBuffer
        Check if the buffer has some bytes to read
        Specified by:
        isReadable in interface DataClayByteBuffer
        Returns:
        TRUE if the buffer has some bytes to read. FALSE otherwise.
      • readableBytes

        public int readableBytes()
        Description copied from interface: DataClayByteBuffer
        Get the number of bytes available to be read.
        Specified by:
        readableBytes in interface DataClayByteBuffer
        Returns:
        The number of bytes available to be read.
      • readerIndex

        public int readerIndex()
        Description copied from interface: DataClayByteBuffer
        Get the index in buffer of the reader pointer
        Specified by:
        readerIndex in interface DataClayByteBuffer
        Returns:
        The index in buffer of the reader pointer
      • writerIndex

        public int writerIndex()
        Description copied from interface: DataClayByteBuffer
        Get the index in buffer of the writer pointer
        Specified by:
        writerIndex in interface DataClayByteBuffer
        Returns:
        The index in buffer of the writer pointer
      • setReaderIndex

        public void setReaderIndex​(int index)
        Description copied from interface: DataClayByteBuffer
        Sets the reader index to the position with index provided
        Specified by:
        setReaderIndex in interface DataClayByteBuffer
        Parameters:
        index - the new reader position
      • setWriterIndex

        public void setWriterIndex​(int index)
        Description copied from interface: DataClayByteBuffer
        Sets the writer index to the position with index provided
        Specified by:
        setWriterIndex in interface DataClayByteBuffer
        Parameters:
        index - the new writer position
      • maxCapacity

        public int maxCapacity()
        Description copied from interface: DataClayByteBuffer
        Gets the maximum capacity of the buffer
        Specified by:
        maxCapacity in interface DataClayByteBuffer
        Returns:
        the maximum capacity of the buffer
      • increaseBufferSize

        public void increaseBufferSize​(int newBufferSize)
        Description copied from interface: DataClayByteBuffer
        Increase the buffer size to a new size provided
        Specified by:
        increaseBufferSize in interface DataClayByteBuffer
        Parameters:
        newBufferSize - The new buffer size
      • getBuffer

        public io.grpc.netty.shaded.io.netty.buffer.ByteBuf getBuffer()
        Description copied from interface: DataClayByteBuffer
        Gets the netty buffer
        Specified by:
        getBuffer in interface DataClayByteBuffer
        Returns:
        The netty buffer
      • setBuffer

        public void setBuffer​(io.grpc.netty.shaded.io.netty.buffer.ByteBuf byteBuf)
        Description copied from interface: DataClayByteBuffer
        Sets the netty buffer
        Specified by:
        setBuffer in interface DataClayByteBuffer
        Parameters:
        byteBuf - the netty buffer to set
      • getArray

        public byte[] getArray()
        Description copied from interface: DataClayByteBuffer
        Gets the byte array used by this buffer
        Specified by:
        getArray in interface DataClayByteBuffer
        Returns:
        the byte array used by this buffer
      • writeInt

        public void writeInt​(int value)
        Description copied from interface: DataClayByteBuffer
        Put an integer into the byte buffer.
        Specified by:
        writeInt in interface DataClayByteBuffer
        Parameters:
        value - Integer to add.
      • writeVLQInt

        public void writeVLQInt​(int value)
        Description copied from interface: DataClayByteBuffer
        Put a variable length integer into the byte buffer.
        Specified by:
        writeVLQInt in interface DataClayByteBuffer
        Parameters:
        value - Integer to represent.
      • readVLQInt

        public int readVLQInt()
        Description copied from interface: DataClayByteBuffer
        Get a variable length integer from the byte buffer.
        Specified by:
        readVLQInt in interface DataClayByteBuffer
        Returns:
        integer represented in byte array.
      • writeInts

        public void writeInts​(int[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of integers into the byte buffer
        Specified by:
        writeInts in interface DataClayByteBuffer
        Parameters:
        values - Array of integers to add.
      • readInts

        public int[] readInts​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of integers from the byte buffer
        Specified by:
        readInts in interface DataClayByteBuffer
        Parameters:
        size - Number of ints to read
        Returns:
        Array of integers read
      • writeByte

        public void writeByte​(byte value)
        Description copied from interface: DataClayByteBuffer
        Put a byte into the byte buffer.
        Specified by:
        writeByte in interface DataClayByteBuffer
        Parameters:
        value - Integer to add.
      • writeBytes

        public void writeBytes​(byte[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of bytes into the byte buffer.
        Specified by:
        writeBytes in interface DataClayByteBuffer
        Parameters:
        values - Array of bytes to add.
      • writeBytes

        public void writeBytes​(io.grpc.netty.shaded.io.netty.buffer.ByteBuf byteBuf)
        Write bytes in byte buffer.
        Parameters:
        byteBuf - Netty byte buffer
      • readBytes

        public void readBytes​(byte[] values)
        Description copied from interface: DataClayByteBuffer
        Get an array of bytes into the variable provided.
        Specified by:
        readBytes in interface DataClayByteBuffer
        Parameters:
        values - destination byte array.
      • writeLong

        public void writeLong​(long value)
        Description copied from interface: DataClayByteBuffer
        Put a long into the byte buffer.
        Specified by:
        writeLong in interface DataClayByteBuffer
        Parameters:
        value - Long to add.
      • writeLongs

        public void writeLongs​(long[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of longs into the byte buffer.
        Specified by:
        writeLongs in interface DataClayByteBuffer
        Parameters:
        values - Array of longs to add.
      • readLongs

        public long[] readLongs​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of longs.
        Specified by:
        readLongs in interface DataClayByteBuffer
        Parameters:
        size - number of longs to read
        Returns:
        An array of longs.
      • readBytes

        public byte[] readBytes​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of bytes.
        Specified by:
        readBytes in interface DataClayByteBuffer
        Parameters:
        size - number of bytes to read
        Returns:
        An array of bytes.
      • writeFloat

        public void writeFloat​(float value)
        Description copied from interface: DataClayByteBuffer
        Put a float into the byte buffer.
        Specified by:
        writeFloat in interface DataClayByteBuffer
        Parameters:
        value - float to add.
      • writeFloats

        public void writeFloats​(float[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of floats into the byte buffer.
        Specified by:
        writeFloats in interface DataClayByteBuffer
        Parameters:
        values - Array of floats to add.
      • readFloats

        public float[] readFloats​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of floats.
        Specified by:
        readFloats in interface DataClayByteBuffer
        Parameters:
        size - number of floats to read
        Returns:
        An array of floats.
      • writeDouble

        public void writeDouble​(double value)
        Description copied from interface: DataClayByteBuffer
        Put a double into the byte buffer.
        Specified by:
        writeDouble in interface DataClayByteBuffer
        Parameters:
        value - double to add.
      • writeDoubles

        public void writeDoubles​(double[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of doubles into the byte buffer.
        Specified by:
        writeDoubles in interface DataClayByteBuffer
        Parameters:
        values - Array of doubles to add.
      • readDoubles

        public double[] readDoubles​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of doubles.
        Specified by:
        readDoubles in interface DataClayByteBuffer
        Parameters:
        size - number of doubles to read
        Returns:
        An array of doubles.
      • writeBoolean

        public void writeBoolean​(boolean value)
        Description copied from interface: DataClayByteBuffer
        Put a boolean into the byte buffer.
        Specified by:
        writeBoolean in interface DataClayByteBuffer
        Parameters:
        value - boolean to add.
      • writeBooleans

        public void writeBooleans​(boolean[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of booleans into the byte buffer.
        Specified by:
        writeBooleans in interface DataClayByteBuffer
        Parameters:
        values - Array of booleans to add.
      • readBooleans

        public boolean[] readBooleans​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of booleans.
        Specified by:
        readBooleans in interface DataClayByteBuffer
        Parameters:
        size - number of booleans to read
        Returns:
        An array of booleans.
      • writeChar

        public void writeChar​(char value)
        Description copied from interface: DataClayByteBuffer
        Put a char into the byte buffer.
        Specified by:
        writeChar in interface DataClayByteBuffer
        Parameters:
        value - char to add.
      • writeChars

        public void writeChars​(char[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of chars into the byte buffer.
        Specified by:
        writeChars in interface DataClayByteBuffer
        Parameters:
        values - Array of chars to add.
      • readChars

        public char[] readChars​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of chars.
        Specified by:
        readChars in interface DataClayByteBuffer
        Parameters:
        size - number of chars to read
        Returns:
        An array of chars.
      • writeShort

        public void writeShort​(short value)
        Description copied from interface: DataClayByteBuffer
        Put a short into the byte buffer.
        Specified by:
        writeShort in interface DataClayByteBuffer
        Parameters:
        value - short to add.
      • writeShorts

        public void writeShorts​(short[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of shorts into the byte buffer.
        Specified by:
        writeShorts in interface DataClayByteBuffer
        Parameters:
        values - Array of shorts to add.
      • readShorts

        public short[] readShorts​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of shorts.
        Specified by:
        readShorts in interface DataClayByteBuffer
        Parameters:
        size - number of shorts to read
        Returns:
        An array of shorts.
      • writeStrings

        public void writeStrings​(String[] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of strings into the byte buffer.
        Specified by:
        writeStrings in interface DataClayByteBuffer
        Parameters:
        values - Array of strings to add.
      • readStrings

        public String[] readStrings​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of strings.
        Specified by:
        readStrings in interface DataClayByteBuffer
        Parameters:
        size - number of strings to read
        Returns:
        An array of strings.
      • writeByteArray

        public void writeByteArray​(byte[] value)
        Description copied from interface: DataClayByteBuffer
        Put a byte array into the byte buffer.
        Specified by:
        writeByteArray in interface DataClayByteBuffer
        Parameters:
        value - byte array to add.
      • writeByteArrays

        public void writeByteArrays​(byte[][] values)
        Description copied from interface: DataClayByteBuffer
        Put an array of byte arrays into the byte buffer.
        Specified by:
        writeByteArrays in interface DataClayByteBuffer
        Parameters:
        values - Array of byte arrays to add.
      • readByteArrays

        public byte[][] readByteArrays​(int size)
        Description copied from interface: DataClayByteBuffer
        Get an array of byte arrays.
        Specified by:
        readByteArrays in interface DataClayByteBuffer
        Parameters:
        size - number of byte arrays to read
        Returns:
        An array of byte arrays.