@InterfaceAudience.Private public class HFileBlock extends Object implements Cacheable
HFile
version 2 file.
Version 2 was introduced in hbase-0.92.0.
Version 1 was the original file block. Version 2 was introduced when we changed the hbase file format to support multi-level block indexes and compound bloom filters (HBASE-3857). Support for Version 1 was removed in hbase-1.3.0.
BlockType
(8 bytes):
e.g. DATABLK*
HFile
. If compression is NONE, this is
just raw, serialized Cells.
Cacheable.serialize(ByteBuffer)
and
Cacheable.getDeserializer()
.
TODO: Should we cache the checksums? Down in Writer#getBlockForCaching(CacheConfig) where we make a block to cache-on-write, there is an attempt at turning off checksums. This is not the only place we get blocks to cache. We also will cache the raw return from an hdfs read. In this case, the checksums may be present. If the cache is backed by something that doesn't do ECC, say an SSD, we might want to preserve checksums. For now this is open question.
TODO: Over in BucketCache, we save a block allocation by doing a custom serialization. Be sure to change it if serialization changes in here. Could we add a method here that takes an IOEngine and that then serializes to it rather than expose our internals over in BucketCache? IOEngine is in the bucket subpackage. Pull it up? Then this class knows about bucketcache. Ugh.
Cacheable.MemoryType
Modifier and Type | Field and Description |
---|---|
static boolean |
DONT_FILL_HEADER |
static boolean |
FILL_HEADER |
static int |
MULTI_BYTE_BUFFER_HEAP_SIZE |
Modifier and Type | Method and Description |
---|---|
HFileBlock |
deepClone() |
boolean |
equals(Object comparison) |
BlockType |
getBlockType() |
ByteBuff |
getBufferReadOnly()
Returns a read-only duplicate of the buffer this block stores internally ready to be read.
|
ByteBuff |
getBufferWithoutHeader()
Returns a buffer that does not include the header or checksum.
|
CacheableDeserializer<Cacheable> |
getDeserializer()
Returns CacheableDeserializer instance which reconstructs original object from ByteBuffer.
|
Cacheable.MemoryType |
getMemoryType() |
ByteBuffer |
getMetaData()
For use by bucketcache.
|
int |
getOnDiskSizeWithHeader() |
int |
getSerializedLength()
Returns the length of the ByteBuffer required to serialized the object.
|
int |
hashCode() |
int |
headerSize()
Returns the size of this block header.
|
static int |
headerSize(boolean usesHBaseChecksum)
Maps a minor version to the size of the header.
|
long |
heapSize() |
boolean |
isUnpacked()
Return true when this block's buffer has been unpacked, false otherwise.
|
void |
serialize(ByteBuffer destination)
Serializes its data into destination.
|
String |
toString() |
public static final boolean FILL_HEADER
public static final boolean DONT_FILL_HEADER
public static final int MULTI_BYTE_BUFFER_HEAP_SIZE
public BlockType getBlockType()
getBlockType
in interface Cacheable
public int getOnDiskSizeWithHeader()
public ByteBuff getBufferWithoutHeader()
public ByteBuff getBufferReadOnly()
CompoundBloomFilter
to avoid object creation on every Bloom
filter lookup, but has to be used with caution. Buffer holds header, block content,
and any follow-on checksums if present.public boolean isUnpacked()
public int getSerializedLength()
Cacheable
getSerializedLength
in interface Cacheable
public void serialize(ByteBuffer destination)
Cacheable
public ByteBuffer getMetaData()
public CacheableDeserializer<Cacheable> getDeserializer()
Cacheable
getDeserializer
in interface Cacheable
public int headerSize()
public static int headerSize(boolean usesHBaseChecksum)
public Cacheable.MemoryType getMemoryType()
getMemoryType
in interface Cacheable
MemoryType
of this Cacheablepublic HFileBlock deepClone()
Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.