private long readAtOffsetWithAllocationAsserts(ByteBuffAllocator alloc, HFile.Reader reader,
    long offset, boolean cacheBlock, BlockType blockType, boolean expectSharedMem)
    throws IOException {
    HFileBlock block;
    try {
      block = reader.readBlock(offset, -1, cacheBlock, true, false, true, blockType, null);
    } catch (IOException e) {
      if (e.getMessage().contains("Expected block type")) {
        return -1;
      }
      throw e;
    }

    Assert.assertEquals(expectSharedMem, block.isSharedMem());

    if (expectSharedMem) {
      Assert.assertTrue(alloc.getFreeBufferCount() < alloc.getTotalBufferCount());
    } else {
      // Should never allocate off-heap block from allocator because ensure that it's LRU.
      Assert.assertEquals(alloc.getTotalBufferCount(), alloc.getFreeBufferCount());
    }

    try {
      return block.getOnDiskSizeWithHeader();
    } finally {
      block.release(); // return back the ByteBuffer back to allocator.
    }
  }
Tests that we properly allocate from the off-heap or on-heap when CombinedCache is configured.
In this case, we should always use off-heap unless the block is an INDEX (which always goes to
L1 cache which is on-heap)
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java