Package org.apache.hadoop.hbase.io.hfile
Interface Cacheable
- All Superinterfaces:
HBaseReferenceCounted
,HeapSize
,org.apache.hbase.thirdparty.io.netty.util.ReferenceCounted
- All Known Implementing Classes:
ExclusiveMemHFileBlock
,HFileBlock
,SharedMemHFileBlock
Cacheable is an interface that allows for an object to be cached. If using an on heap cache, just
use heapsize. If using an off heap cache, Cacheable provides methods for serialization of the
object. Some objects cannot be moved off heap, those objects will return a getSerializedLength()
of 0.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the block type of this cached HFile blockReturns CacheableDeserializer instance which reconstructs original object from ByteBuffer.int
Returns the length of the ByteBuffer required to serialized the object.default int
refCnt()
Reference count of this Cacheable.default boolean
release()
Decrease its reference count, and if no reference then free the memory of this object, its backend is usually aByteBuff
, and we will put its NIO ByteBuffers back toByteBuffAllocator
default Cacheable
retain()
Increase its reference count, and only when no reference we can free the object's memory.void
serialize
(ByteBuffer destination, boolean includeNextBlockMetadata) Serializes its data into destination.Methods inherited from interface org.apache.hadoop.hbase.nio.HBaseReferenceCounted
release, retain, touch, touch
-
Method Details
-
getSerializedLength
int getSerializedLength()Returns the length of the ByteBuffer required to serialized the object. If the object cannot be serialized, it should return 0.- Returns:
- int length in bytes of the serialized form or 0 if the object cannot be cached.
-
serialize
Serializes its data into destination.- Parameters:
destination
- Where to serialize toincludeNextBlockMetadata
- Whether to include nextBlockMetadata in the Cache block.
-
getDeserializer
Returns CacheableDeserializer instance which reconstructs original object from ByteBuffer.- Returns:
- CacheableDeserialzer instance.
-
getBlockType
Returns the block type of this cached HFile block -
retain
Increase its reference count, and only when no reference we can free the object's memory.- Specified by:
retain
in interfaceorg.apache.hbase.thirdparty.io.netty.util.ReferenceCounted
-
refCnt
Reference count of this Cacheable.- Specified by:
refCnt
in interfaceorg.apache.hbase.thirdparty.io.netty.util.ReferenceCounted
-
release
Decrease its reference count, and if no reference then free the memory of this object, its backend is usually aByteBuff
, and we will put its NIO ByteBuffers back toByteBuffAllocator
- Specified by:
release
in interfaceorg.apache.hbase.thirdparty.io.netty.util.ReferenceCounted
-