private void testPrefetchWhenRefs(boolean compactionEnabled, Consumer<Cacheable> test)
    throws Exception {
    cacheConf = new CacheConfig(conf, blockCache);
    HFileContext context = new HFileContextBuilder().withBlockSize(DATA_BLOCK_SIZE).build();
    Path tableDir = new Path(TEST_UTIL.getDataTestDir(), "testPrefetchSkipRefs");
    RegionInfo region =
      RegionInfoBuilder.newBuilder(TableName.valueOf("testPrefetchSkipRefs")).build();
    Path regionDir = new Path(tableDir, region.getEncodedName());
    Pair<Path, byte[]> fileWithSplitPoint =
      writeStoreFileForSplit(new Path(regionDir, "cf"), context);
    Path storeFile = fileWithSplitPoint.getFirst();
    HRegionFileSystem regionFS =
      HRegionFileSystem.createRegionOnFileSystem(conf, fs, tableDir, region);
    StoreFileTracker sft = StoreFileTrackerFactory.create(conf, true,
      StoreContext.getBuilder().withFamilyStoreDirectoryPath(new Path(regionDir, "cf"))
        .withRegionFileSystem(regionFS).build());
    HStoreFile file = new HStoreFile(fs, storeFile, conf, cacheConf, BloomType.NONE, true, sft);
    Path ref = regionFS.splitStoreFile(region, "cf", file, fileWithSplitPoint.getSecond(), false,
      new ConstantSizeRegionSplitPolicy(), sft);
    conf.setBoolean(HBASE_REGION_SERVER_ENABLE_COMPACTION, compactionEnabled);
    HStoreFile refHsf = new HStoreFile(this.fs, ref, conf, cacheConf, BloomType.NONE, true, sft);
    refHsf.initReader();
    HFile.Reader reader = refHsf.getReader().getHFileReader();
    while (!reader.prefetchComplete()) {
      // Sleep for a bit
      Thread.sleep(1000);
    }
    long offset = 0;
    while (offset < reader.getTrailer().getLoadOnOpenDataOffset()) {
      HFileBlock block = reader.readBlock(offset, -1, false, true, false, true, null, null, true);
      BlockCacheKey blockCacheKey = new BlockCacheKey(reader.getName(), offset);
      if (block.getBlockType() == BlockType.DATA) {
        test.accept(blockCache.getBlock(blockCacheKey, true, false, true));
      }
      offset += block.getOnDiskSizeWithHeader();
    }
  }
Read a storefile in the same manner as a scanner -- using non-positional reads and without
waiting for prefetch to complete.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestPrefetch.java