public abstract class HFileBlock extends Object
HFileBlockType.| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
byteBuff |
protected int |
bytesPerChecksum |
protected byte[] |
compressedByteBuff |
protected HFileContext |
context |
static int |
HFILEBLOCK_HEADER_SIZE |
static int |
HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM |
protected int |
onDiskSizeWithoutHeader |
protected int |
sizeCheckSum |
protected int |
startOffsetInBuff |
protected int |
startOffsetInCompressedBuff |
protected int |
uncompressedEndOffset |
protected int |
uncompressedSizeWithoutHeader |
| Modifier | Constructor and Description |
|---|---|
protected |
HFileBlock(HFileContext context,
HFileBlockType blockType,
byte[] byteBuff,
int startOffsetInBuff)
Initialize HFileBlock for read.
|
protected |
HFileBlock(HFileContext context,
HFileBlockType blockType,
long previousBlockOffsetForWrite)
Initialize HFileBlock for write.
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
allocateBufferForUnpacking()
Allocates new byte buffer for the uncompressed bytes.
|
HFileBlockType |
getBlockType() |
byte[] |
getByteBuff() |
int |
getOnDiskSizeWithHeader() |
protected long |
getStartOffsetInBuffForWrite()
Gets start offset of the block in the buffer.
|
protected abstract ByteBuffer |
getUncompressedBlockDataToWrite()
Returns serialized "data" part of the block.
|
static HFileBlock |
parse(HFileContext context,
byte[] byteBuff,
int startOffsetInBuff)
Parses the HFile block header and returns the
HFileBlock instance based on the input. |
ByteBuffer |
serialize()
Return serialized block including header, data, checksum.
|
protected void |
setStartOffsetInBuffForWrite(long startOffsetInBuffForWrite)
Sets start offset of the block in the buffer.
|
void |
unpack()
Decodes and decompresses the block content if the block content is compressed.
|
public static final int HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM
public static final int HFILEBLOCK_HEADER_SIZE
protected final HFileContext context
protected final byte[] byteBuff
protected final int startOffsetInBuff
protected final int sizeCheckSum
protected final int uncompressedEndOffset
protected final int onDiskSizeWithoutHeader
protected final int uncompressedSizeWithoutHeader
protected final int bytesPerChecksum
protected byte[] compressedByteBuff
protected int startOffsetInCompressedBuff
protected HFileBlock(HFileContext context, HFileBlockType blockType, byte[] byteBuff, int startOffsetInBuff)
protected HFileBlock(HFileContext context, HFileBlockType blockType, long previousBlockOffsetForWrite)
public static HFileBlock parse(HFileContext context, byte[] byteBuff, int startOffsetInBuff) throws IOException
HFileBlock instance based on the input.context - HFile context.byteBuff - input data.startOffsetInBuff - offset to start parsing.HFileBlock instance based on the input.IOException - if the block cannot be parsed.public HFileBlockType getBlockType()
public byte[] getByteBuff()
public int getOnDiskSizeWithHeader()
public void unpack()
throws IOException
This must be called for an encoded and compressed block before any reads.
IOException - upon decoding and decompression error.protected byte[] allocateBufferForUnpacking()
protected abstract ByteBuffer getUncompressedBlockDataToWrite() throws IOException
IOExceptionpublic ByteBuffer serialize() throws IOException
IOExceptionprotected void setStartOffsetInBuffForWrite(long startOffsetInBuffForWrite)
protected long getStartOffsetInBuffForWrite()
Copyright © 2025 The Apache Software Foundation. All rights reserved.