Package db.buffers
Class BufferFileBlock
java.lang.Object
db.buffers.BufferFileBlock
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
ConstructorDescriptionBufferFileBlock
(byte[] bytes) BufferFileBlock constructor for use when reconstructing instance from block streamBufferFileBlock
(int blockIndex, byte[] buffer) BufferFileBlock constructor -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
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 Details
-
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 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
-