HFileBlock getBlockForCaching(CacheConfig cacheConf) {
      HFileContext newContext = BlockCacheUtil.cloneContext(fileContext);
      // Build the HFileBlock.
      HFileBlockBuilder builder = new HFileBlockBuilder();
      ByteBuff buff;
      if (cacheConf.shouldCacheCompressed(blockType.getCategory())) {
        buff = cloneOnDiskBufferWithHeader();
      } else {
        buff = cloneUncompressedBufferWithHeader();
      }
      return builder.withBlockType(blockType)
        .withOnDiskSizeWithoutHeader(getOnDiskSizeWithoutHeader())
        .withUncompressedSizeWithoutHeader(getUncompressedSizeWithoutHeader())
        .withPrevBlockOffset(prevOffset).withByteBuff(buff).withFillHeader(FILL_HEADER)
        .withOffset(startOffset).withNextBlockOnDiskSize(UNSET)
        .withOnDiskDataSizeWithHeader(onDiskBlockBytesWithHeader.size() + onDiskChecksum.length)
        .withHFileContext(newContext).withByteBuffAllocator(cacheConf.getByteBuffAllocator())
        .withShared(!buff.hasArray()).build();
    }
Creates a new HFileBlock. Checksums have already been validated, so the byte buffer passed
into the constructor of this newly created block does not have checksum data even though the
header minor version is MINOR_VERSION_WITH_CHECKSUM. This is indicated by setting a 0 value
in bytesPerChecksum. This method copies the on-disk or uncompressed data to build the
HFileBlock which is used only while writing blocks and caching.
<p>
TODO: Should there be an option where a cache can ask that hbase preserve block checksums for
checking after a block comes out of the cache? Otehrwise, cache is responsible for blocks
being wholesome (ECC memory or if file-backed, it does checksumming).
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java