Package alluxio.file

Class ByteArrayTargetBuffer

  • All Implemented Interfaces:
    ReadTargetBuffer

    public class ByteArrayTargetBuffer
    extends java.lang.Object
    implements ReadTargetBuffer
    Target buffer backed by bytes array for zero-copy read from page store.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteArrayTargetBuffer​(byte[] target, int offset)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] byteArray()  
      java.nio.ByteBuffer byteBuffer()  
      java.nio.channels.WritableByteChannel byteChannel()  
      int offset()  
      void offset​(int newOffset)
      Sets the new offset in the buffer.
      int readFromFile​(java.io.RandomAccessFile file, int length)  
      int readFromInputStream​(java.io.InputStream is, int length)  
      long remaining()  
      void writeBytes​(byte[] srcArray, int srcOffset, int length)  
      void writeBytes​(io.netty.buffer.ByteBuf buf)  
      • Methods inherited from class java.lang.Object

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

      • ByteArrayTargetBuffer

        public ByteArrayTargetBuffer​(byte[] target,
                                     int offset)
        Constructor.
        Parameters:
        target -
        offset -
    • Method Detail

      • byteBuffer

        public java.nio.ByteBuffer byteBuffer()
        Specified by:
        byteBuffer in interface ReadTargetBuffer
        Returns:
        the byte buffer
      • offset

        public int offset()
        Specified by:
        offset in interface ReadTargetBuffer
        Returns:
        offset in the buffer
      • offset

        public void offset​(int newOffset)
        Description copied from interface: ReadTargetBuffer
        Sets the new offset in the buffer.
        Specified by:
        offset in interface ReadTargetBuffer
        Parameters:
        newOffset - the new offset
      • remaining

        public long remaining()
        Specified by:
        remaining in interface ReadTargetBuffer
        Returns:
        the remaining for this buffer
      • writeBytes

        public void writeBytes​(byte[] srcArray,
                               int srcOffset,
                               int length)
        Specified by:
        writeBytes in interface ReadTargetBuffer
      • readFromFile

        public int readFromFile​(java.io.RandomAccessFile file,
                                int length)
                         throws java.io.IOException
        Specified by:
        readFromFile in interface ReadTargetBuffer
        Returns:
        bytes read from the file
        Throws:
        java.io.IOException
      • readFromInputStream

        public int readFromInputStream​(java.io.InputStream is,
                                       int length)
                                throws java.io.IOException
        Specified by:
        readFromInputStream in interface ReadTargetBuffer
        Returns:
        bytes read from input stream
        Throws:
        java.io.IOException
      • byteChannel

        public java.nio.channels.WritableByteChannel byteChannel()
        Specified by:
        byteChannel in interface ReadTargetBuffer
        Returns:
        the writable channel