private void testDataBlockSizeWithCompressionRatePredicator(int expectedBlockCount,
    BiFunction<Integer, Integer, Boolean> validation) throws Exception {
    Path dir = new Path(new Path(this.testDir, "7e0102"), "familyname");
    Path path = new Path(dir, "1234567890");
    DataBlockEncoding dataBlockEncoderAlgo = DataBlockEncoding.FAST_DIFF;
    cacheConf = new CacheConfig(conf);
    HFileContext meta =
      new HFileContextBuilder().withBlockSize(BLOCKSIZE_SMALL).withChecksumType(CKTYPE)
        .withBytesPerCheckSum(CKBYTES).withDataBlockEncoding(dataBlockEncoderAlgo)
        .withCompression(Compression.Algorithm.GZ).build();
    // Make a store file and write data to it.
    StoreFileWriter writer = new StoreFileWriter.Builder(conf, cacheConf, this.fs)
      .withFilePath(path).withMaxKeyCount(2000).withFileContext(meta).build();
    writeLargeStoreFile(writer, Bytes.toBytes(name.getMethodName()),
      Bytes.toBytes(name.getMethodName()), 200);
    writer.close();
    StoreFileInfo storeFileInfo =
      StoreFileInfo.createStoreFileInfoForHFile(conf, fs, writer.getPath(), true);
    HStoreFile storeFile = new HStoreFile(storeFileInfo, BloomType.NONE, cacheConf);
    storeFile.initReader();
    HFile.Reader fReader =
      HFile.createReader(fs, writer.getPath(), storeFile.getCacheConf(), true, conf);
    FSDataInputStreamWrapper fsdis = new FSDataInputStreamWrapper(fs, writer.getPath());
    long fileSize = fs.getFileStatus(writer.getPath()).getLen();
    FixedFileTrailer trailer = FixedFileTrailer.readFromStream(fsdis.getStream(false), fileSize);
    long offset = trailer.getFirstDataBlockOffset(), max = trailer.getLastDataBlockOffset();
    HFileBlock block;
    int blockCount = 0;
    while (offset <= max) {
      block = fReader.readBlock(offset, -1, /* cacheBlock */ false, /* pread */ false,
        /* isCompaction */ false, /* updateCacheMetrics */ false, null, null);
      offset += block.getOnDiskSizeWithHeader();
      blockCount++;
      assertTrue(validation.apply(block.getUncompressedSizeWithoutHeader(), blockCount));
    }
    assertEquals(expectedBlockCount, blockCount);
  }
Check if data block encoding information is saved correctly in HFile's file info.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java