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

    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

    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

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

    • BufferFileBlock

      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

      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

    • size

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

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

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

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