public class HFileBlock extends SchemaConfigured implements Cacheable
HFile
version 1 and 2 blocks, and writing version 2 blocks.
HFile
's compression algorithm, with a type-specific
magic record stored in the beginning of the compressed data (i.e. one needs
to uncompress the compressed block to determine the block type). There is
only a single compression algorithm setting for all blocks. Offset and size
information from the block index are required to read a block.
HFile
,
similarly to what was done in version 1.
Modifier and Type | Class and Description |
---|---|
static interface |
HFileBlock.BlockIterator
An interface allowing to iterate
HFileBlock s. |
static interface |
HFileBlock.BlockWritable
Something that can be written into a block.
|
static interface |
HFileBlock.FSReader
A full-fledged reader with iteration ability.
|
static class |
HFileBlock.Writer
Unified version 2
HFile block writer. |
Modifier and Type | Field and Description |
---|---|
static int |
BYTE_BUFFER_HEAP_SIZE |
static boolean |
DONT_FILL_HEADER |
static int |
ENCODED_HEADER_SIZE
The size of block header when blockType is
BlockType.ENCODED_DATA . |
static boolean |
FILL_HEADER |
SCHEMA_CONFIGURED_UNALIGNED_HEAP_SIZE
Modifier and Type | Method and Description |
---|---|
void |
assumeUncompressed()
An additional sanity-check in case no compression is being used.
|
boolean |
doesIncludeMemstoreTS() |
boolean |
equals(Object comparison) |
void |
expectType(BlockType expectedType) |
BlockType |
getBlockType() |
ByteBuffer |
getBufferReadOnly()
Returns the buffer this block stores internally.
|
DataInputStream |
getByteStream() |
DataBlockEncoding |
getDataBlockEncoding() |
short |
getDataBlockEncodingId() |
CacheableDeserializer<Cacheable> |
getDeserializer()
Returns CacheableDeserializer instance which reconstructs original object from ByteBuffer.
|
byte[] |
getDummyHeaderForVersion()
Return the appropriate DUMMY_HEADER_WITH_CHECKSUM for the minor version
|
int |
getNextBlockOnDiskSizeWithHeader() |
long |
getOffset() |
int |
getOnDiskSizeWithHeader() |
long |
getPrevBlockOffset() |
int |
getSerializedLength()
Returns the length of the ByteBuffer required to serialized the object.
|
int |
getUncompressedSizeWithoutHeader() |
int |
headerSize()
Returns the size of this block header.
|
long |
heapSize() |
static boolean |
readWithExtra(InputStream in,
byte[] buf,
int bufOffset,
int necessaryLen,
int extraLen)
Read from an input stream.
|
void |
serialize(ByteBuffer destination)
Serializes its data into destination.
|
String |
toString() |
createUnknown, getColumnFamilyName, getSchemaMetrics, getTableName, isSchemaConfigured, passSchemaMetricsTo, resetSchemaMetricsConf, schemaConfAsJSON, schemaConfigurationChanged
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSchemaMetrics
public static final boolean FILL_HEADER
public static final boolean DONT_FILL_HEADER
public static final int ENCODED_HEADER_SIZE
BlockType.ENCODED_DATA
.
This extends normal header by adding the id of encoder.public static final int BYTE_BUFFER_HEAP_SIZE
public BlockType getBlockType()
getBlockType
in interface Cacheable
public short getDataBlockEncodingId()
public int getOnDiskSizeWithHeader()
public int getUncompressedSizeWithoutHeader()
public long getPrevBlockOffset()
public ByteBuffer getBufferReadOnly()
CompoundBloomFilter
to avoid object creation on every
Bloom filter lookup, but has to be used with caution. Checksum data
is not included in the returned buffer.public void assumeUncompressed() throws IOException
IOException
public void expectType(BlockType expectedType) throws IOException
expectedType
- the expected type of this blockIOException
- if this block's type is different than expectedpublic long getOffset()
public DataInputStream getByteStream()
public long heapSize()
heapSize
in interface HeapSize
heapSize
in class SchemaConfigured
public static boolean readWithExtra(InputStream in, byte[] buf, int bufOffset, int necessaryLen, int extraLen) throws IOException
IOUtils.readFully(InputStream, byte[], int, int)
, but specifies a
number of "extra" bytes that would be desirable but not absolutely
necessary to read.in
- the input stream to read frombuf
- the buffer to read intobufOffset
- the destination offset in the buffernecessaryLen
- the number of bytes that are absolutely necessary to
readextraLen
- the number of extra bytes that would be nice to readIOException
- if failed to read the necessary bytespublic int getNextBlockOnDiskSizeWithHeader()
public int getSerializedLength()
Cacheable
getSerializedLength
in interface Cacheable
public void serialize(ByteBuffer destination)
Cacheable
public CacheableDeserializer<Cacheable> getDeserializer()
Cacheable
getDeserializer
in interface Cacheable
public boolean doesIncludeMemstoreTS()
public DataBlockEncoding getDataBlockEncoding()
public int headerSize()
public byte[] getDummyHeaderForVersion()
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.