Package db.buffers
Class BufferFileBlock
- java.lang.Object
-
- db.buffers.BufferFileBlock
-
public class BufferFileBlock extends java.lang.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 streamBufferFileBlock(int blockIndex, byte[] buffer)
BufferFileBlock constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getData()
Get block data bufferint
getIndex()
Get absolute block index, where 0 corresponds to the first physical block within the buffer file.int
size()
Get block sizebyte[]
toBytes()
Get block as byte array suitable for use in block stream and reconstruction.
-
-
-
Constructor Detail
-
BufferFileBlock
public BufferFileBlock(int blockIndex, byte[] buffer)
BufferFileBlock constructor- Parameters:
blockIndex
- block indexbuffer
- 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 Detail
-
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
-
-