Class Chunk


  • public class Chunk
    extends java.lang.Object
    Class for handling data belonging to a single chunk.
    • Constructor Summary

      Constructors 
      Constructor Description
      Chunk​(java.io.DataInput input, int offset, byte[] reusableBuffer)  
    • Field Detail

      • input

        private final java.io.DataInput input
      • majorVersion

        private final short majorVersion
      • minorVersion

        private final short minorVersion
      • position

        private int position
      • data

        private byte[] data
    • Constructor Detail

      • Chunk

        public Chunk​(java.io.DataInput input,
                     int offset,
                     byte[] reusableBuffer)
              throws java.io.IOException,
                     InvalidJfrFileException
        Parameters:
        input - input to read chunk data from
        offset - initial position
        reusableBuffer - a byte array for holding read chunk data
        Throws:
        java.io.IOException
        InvalidJfrFileException
    • Method Detail

      • getMajorVersion

        public short getMajorVersion()
      • getMinorVersion

        public short getMinorVersion()
      • getPosition

        public int getPosition()
      • fill

        public byte[] fill​(long upToPosition)
                    throws java.io.IOException,
                           InvalidJfrFileException
        Copy data from the input source to the chunk buffer. Note that this may replace the buffer if it is not large enough.
        Parameters:
        upToPosition - position to fill buffer to
        Returns:
        the current buffer for the chunk data
        Throws:
        java.io.IOException
        InvalidJfrFileException
      • skip

        public void skip​(long upToPosition)
                  throws java.io.IOException,
                         InvalidJfrFileException
        Skip reading data from the input source up to a specified position. Note that the skipped data can not be read later from the same input source.
        Parameters:
        upToPosition - chunk relative position
        Throws:
        java.io.IOException
        InvalidJfrFileException
      • getReusableBuffer

        public byte[] getReusableBuffer()
        Return the current data buffer. Note that the returned array is only guaranteed to contain data up to the read position when this method is called. If the buffer is filled more later, then that data may end up in a new array.
        Returns:
        the current chunk data buffer