public static HFileBlock getBlockForCaching(CacheConfig cacheConf, HFileBlock block) {
    // Calculate how many bytes we need for checksum on the tail of the block.
    int numBytes = cacheConf.shouldCacheCompressed(block.getBlockType().getCategory())
      ? 0
      : (int) ChecksumUtil.numBytes(block.getOnDiskDataSizeWithHeader(),
        block.getHFileContext().getBytesPerChecksum());
    ByteBuff buff = block.getBufferReadOnly();
    HFileBlockBuilder builder = new HFileBlockBuilder();
    return builder.withBlockType(block.getBlockType())
      .withOnDiskSizeWithoutHeader(block.getOnDiskSizeWithoutHeader())
      .withUncompressedSizeWithoutHeader(block.getUncompressedSizeWithoutHeader())
      .withPrevBlockOffset(block.getPrevBlockOffset()).withByteBuff(buff)
      .withFillHeader(FILL_HEADER).withOffset(block.getOffset()).withNextBlockOnDiskSize(-1)
      .withOnDiskDataSizeWithHeader(block.getOnDiskDataSizeWithHeader() + numBytes)
      .withNextBlockOnDiskSize(block.getNextBlockOnDiskSize())
      .withHFileContext(cloneContext(block.getHFileContext()))
      .withByteBuffAllocator(cacheConf.getByteBuffAllocator()).withShared(!buff.hasArray()).build();
  }
Similarly to HFileBlock.Writer.getBlockForCaching(), creates a HFileBlock instance without
checksum for caching. This is needed for when we cache blocks via readers (either prefetch or
client read), otherwise we may fail equality comparison when checking against same block that
may already have been cached at write time.
@param cacheConf the related CacheConfig object.
@param block     the HFileBlock instance to be converted.
@return the resulting HFileBlock instance without checksum.
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java