Interface Cacheable

All Superinterfaces:
HBaseReferenceCounted, HeapSize, org.apache.hbase.thirdparty.io.netty.util.ReferenceCounted
All Known Implementing Classes:
ExclusiveMemHFileBlock, HFileBlock, SharedMemHFileBlock

@Private public interface Cacheable extends HeapSize, HBaseReferenceCounted
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 Type
    Method
    Description
    Returns the block type of this cached HFile block
    Returns CacheableDeserializer instance which reconstructs original object from ByteBuffer.
    int
    Returns the length of the ByteBuffer required to serialized the object.
    default int
    Reference count of this Cacheable.
    default boolean
    Decrease its reference count, and if no reference then free the memory of this object, its backend is usually a ByteBuff, and we will put its NIO ByteBuffers back to ByteBuffAllocator
    default Cacheable
    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

    Methods inherited from interface org.apache.hadoop.hbase.io.HeapSize

    heapSize
  • Method Details

    • 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

      void serialize(ByteBuffer destination, boolean includeNextBlockMetadata)
      Serializes its data into destination.
      Parameters:
      destination - Where to serialize to
      includeNextBlockMetadata - 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

      default Cacheable retain()
      Increase its reference count, and only when no reference we can free the object's memory.
      Specified by:
      retain in interface org.apache.hbase.thirdparty.io.netty.util.ReferenceCounted
    • refCnt

      default int refCnt()
      Reference count of this Cacheable.
      Specified by:
      refCnt in interface org.apache.hbase.thirdparty.io.netty.util.ReferenceCounted
    • release

      default boolean release()
      Decrease its reference count, and if no reference then free the memory of this object, its backend is usually a ByteBuff, and we will put its NIO ByteBuffers back to ByteBuffAllocator
      Specified by:
      release in interface org.apache.hbase.thirdparty.io.netty.util.ReferenceCounted