Package alluxio.grpc

Class ReadableDataBuffer

  • All Implemented Interfaces:
    DataBuffer

    public class ReadableDataBuffer
    extends java.lang.Object
    implements DataBuffer
    Class for making wrapping ReadableBuffer as DataBuffer.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReadableDataBuffer​(io.grpc.internal.ReadableBuffer buffer)
      Creates DataBuffer for reading.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getLength()
      Returns the length of the data.
      java.lang.Object getNettyOutput()
      Returns an object for writing to a netty channel.
      java.nio.ByteBuffer getReadOnlyByteBuffer()
      Returns a ByteBuffer for read-only access to the data.
      int readableBytes()  
      void readBytes​(byte[] dst, int dstIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
      void readBytes​(java.io.OutputStream outputStream, int length)
      Transfers this buffer's data to the given stream.
      void readBytes​(java.nio.ByteBuffer outputBuf)
      Transfers this buffer's data to the given ByteBuffer.
      void release()
      Releases the underlying buffer of this DataBuffer if no longer needed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReadableDataBuffer

        public ReadableDataBuffer​(io.grpc.internal.ReadableBuffer buffer)
        Creates DataBuffer for reading.
        Parameters:
        buffer - internal buffer
    • Method Detail

      • getNettyOutput

        public java.lang.Object getNettyOutput()
        Description copied from interface: DataBuffer
        Returns an object for writing to a netty channel.
        Specified by:
        getNettyOutput in interface DataBuffer
        Returns:
        the object to output to Netty. Must be ByteBuf or FileRegion
      • getLength

        public long getLength()
        Description copied from interface: DataBuffer
        Returns the length of the data.
        Specified by:
        getLength in interface DataBuffer
        Returns:
        the length of the data in bytes
      • getReadOnlyByteBuffer

        public java.nio.ByteBuffer getReadOnlyByteBuffer()
        Description copied from interface: DataBuffer
        Returns a ByteBuffer for read-only access to the data.
        Specified by:
        getReadOnlyByteBuffer in interface DataBuffer
        Returns:
        a read-only ByteBuffer representing the data
      • readBytes

        public void readBytes​(java.nio.ByteBuffer outputBuf)
        Description copied from interface: DataBuffer
        Transfers this buffer's data to the given ByteBuffer.
        Specified by:
        readBytes in interface DataBuffer
        Parameters:
        outputBuf - the buffer to transfer data to
      • readBytes

        public void readBytes​(byte[] dst,
                              int dstIndex,
                              int length)
        Description copied from interface: DataBuffer
        Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
        Specified by:
        readBytes in interface DataBuffer
        Parameters:
        dst - the destination
        dstIndex - the first index of the destination
        length - the number of bytes to transfer
      • readBytes

        public void readBytes​(java.io.OutputStream outputStream,
                              int length)
                       throws java.io.IOException
        Description copied from interface: DataBuffer
        Transfers this buffer's data to the given stream.
        Specified by:
        readBytes in interface DataBuffer
        Parameters:
        outputStream - the stream to transfer data to
        length - length of the data to be transferred
        Throws:
        java.io.IOException
      • readableBytes

        public int readableBytes()
        Specified by:
        readableBytes in interface DataBuffer
        Returns:
        the number of readable bytes remaining
      • release

        public void release()
        Description copied from interface: DataBuffer
        Releases the underlying buffer of this DataBuffer if no longer needed.
        Specified by:
        release in interface DataBuffer