Class ByteBufDataChunk

  • All Implemented Interfaces:
    DataChunk, Iterable<ByteBuffer>

    public class ByteBufDataChunk
    extends Object
    implements DataChunk
    A special DataChunk implementation based on Netty's buffers. This is used by our Jersey SPI implementation to take advantage of Netty's buffer pooling.
    • Method Detail

      • create

        public static ByteBufDataChunk create​(boolean flush,
                                              boolean readOnly,
                                              io.netty.buffer.ByteBuf... byteBufs)
        Creates an instance given an array of ByteBuf's.
        Parameters:
        flush - a signal that this chunk should be written and flushed from any cache if possible
        readOnly - marks this buffer as read only
        byteBufs - the data for this chunk. Should not be reused until releaseCallback is used
        Returns:
        new chunk
      • create

        public static ByteBufDataChunk create​(boolean flush,
                                              boolean readOnly,
                                              Runnable releaseCallback,
                                              io.netty.buffer.ByteBuf... byteBufs)
        Creates an instance given an array of ByteBuf's.
        Parameters:
        flush - a signal that this chunk should be written and flushed from any cache if possible
        readOnly - marks this buffer as read only
        releaseCallback - a callback which is called when this chunk is completely processed
        byteBufs - the data for this chunk. Should not be reused until releaseCallback is used
        Returns:
        new chunk
      • data

        public <T> T[] data​(Class<T> clazz)
        Specified by:
        data in interface DataChunk
      • flush

        public boolean flush()
        Specified by:
        flush in interface DataChunk
      • release

        public void release()
        Specified by:
        release in interface DataChunk
      • data

        public ByteBuffer[] data()
        This method is needed for testing some of our examples. It bypasses the optimization for which this class was created.
        Specified by:
        data in interface DataChunk
        Returns:
        array of ByteBuffer
      • bytes

        public byte[] bytes()
        Specified by:
        bytes in interface DataChunk