private static ByteBufferKeyValue buildOffHeapKeyValue(KeyValue keyValue) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    keyValue.write(out, false);
    byte[] bytes = out.toByteArray();
    ByteBuffer bb = ByteBuffer.allocateDirect(bytes.length);
    bb.put(bytes);
    bb.flip();

    return new ByteBufferKeyValue(bb, 0, bytes.length);
  }
Test whether the decompression of first key is implemented correctly.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java