Package db.buffers

Class BufferFileBlock

java.lang.Object
db.buffers.BufferFileBlock

public class BufferFileBlock extends Object
BufferFileBlock is used to hold BufferFile blocks for use during block streaming operations.

Block indexes are absolute where 0 corresponds to the head block in the BufferFile. It is important to note that this number is off by 1 from DataBuffer numbering and the index values utilized by BufferFile.getIndexCount(), BufferFile.get(DataBuffer, int), BufferFile.put(DataBuffer, int), etc.. It is important for each implementation to normalize to absolute block indexes.

  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    BufferFileBlock(byte[] bytes)
    BufferFileBlock constructor for use when reconstructing instance from block stream
    BufferFileBlock(int blockIndex, byte[] buffer)
    BufferFileBlock constructor
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    byte[]
    Get block data buffer
    int
    Get absolute block index, where 0 corresponds to the first physical block within the buffer file.
    int
    Get block size
    byte[]
    Get block as byte array suitable for use in block stream and reconstruction.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

    • BufferFileBlock Link icon

      public BufferFileBlock(int blockIndex, byte[] buffer)
      BufferFileBlock constructor
      Parameters:
      blockIndex - block index
      buffer - block buffer (size must match block-size for associated buffer file)
    • BufferFileBlock Link icon

      public BufferFileBlock(byte[] bytes)
      BufferFileBlock constructor for use when reconstructing instance from block stream
      Parameters:
      bytes - buffer data received from block stream. Buffer index will be determined by first 4-bytes contained within the bytes array (big-endian).
  • Method Details Link icon

    • size Link icon

      public int size()
      Get block size
      Returns:
      block size
    • getIndex Link icon

      public int getIndex()
      Get absolute block index, where 0 corresponds to the first physical block within the buffer file.
      Returns:
      block index
    • getData Link icon

      public byte[] getData()
      Get block data buffer
      Returns:
      block data buffer
    • toBytes Link icon

      public byte[] toBytes()
      Get block as byte array suitable for use in block stream and reconstruction.
      Returns:
      block as byte array