private long scanBlocks(int entryCount, HFileContext context, List<KeyValue> keyValues,
    FSDataInputStream fsdis, FixedFileTrailer trailer, HFileContext meta,
    HFileBlock.FSReader blockReader, int entriesRead, int blocksRead, DataBlockEncoder encoder)
    throws IOException {
    // Scan blocks the way the reader would scan them
    fsdis.seek(0);
    long curBlockPos = 0;
    while (curBlockPos <= trailer.getLastDataBlockOffset()) {
      HFileBlockDecodingContext ctx = blockReader.getBlockDecodingContext();
      HFileBlock block =
        blockReader.readBlockData(curBlockPos, -1, false, false, true).unpack(context, blockReader);
      Assert.assertEquals(BlockType.ENCODED_DATA, block.getBlockType());
      ByteBuff origBlock = block.getBufferReadOnly();
      int pos = block.headerSize() + DataBlockEncoding.ID_SIZE;
      origBlock.position(pos);
      origBlock.limit(pos + block.getUncompressedSizeWithoutHeader() - DataBlockEncoding.ID_SIZE);
      ByteBuff buf = origBlock.slice();
      DataBlockEncoder.EncodedSeeker seeker =
        encoder.createSeeker(encoder.newDataBlockDecodingContext(conf, meta));
      seeker.setCurrentBuffer(buf);
      Cell res = seeker.getCell();
      KeyValue kv = keyValues.get(entriesRead);
      Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(res, kv));
      ++entriesRead;
      while (seeker.next()) {
        res = seeker.getCell();
        kv = keyValues.get(entriesRead);
        Assert.assertEquals(0, CellComparatorImpl.COMPARATOR.compare(res, kv));
        ++entriesRead;
      }
      ++blocksRead;
      curBlockPos += block.getOnDiskSizeWithHeader();
    }
    LOG.info("Finished reading: entries={}, blocksRead = {}", entriesRead, blocksRead);
    Assert.assertEquals(entryCount, entriesRead);
    return curBlockPos;
  }
Testing writing a version 3 {@link HFile} for all encoded blocks
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileWriterV3WithDataEncoders.java