private boolean canDecompressViaByteBuff(ByteBuff blockBufferWithoutHeader,
    ByteBuff onDiskBlock) {
    // Theoretically we can do ByteBuff decompression after doing streaming decryption, but the
    // refactoring necessary to support this has not been attempted. For now, we skip ByteBuff
    // decompression if the input is encrypted.
    if (fileContext.getEncryptionContext() != Encryption.Context.NONE) {
      return false;
    } else if (!fileContext.getCompression().supportsByteBuffDecompression()) {
      return false;
    } else {
      ByteBuffDecompressor decompressor = fileContext.getCompression().getByteBuffDecompressor();
      try {
        decompressor.reinit(fileContext.getDecompressionContext());
        // Even if we have a ByteBuffDecompressor, we still need to check if it can decompress
        // our particular ByteBuffs
        return decompressor.canDecompress(blockBufferWithoutHeader, onDiskBlock);
      } finally {
        fileContext.getCompression().returnByteBuffDecompressor(decompressor);
      }
    }
  }
When only decompression is needed (not decryption), and the input and output buffers are
SingleByteBuffs, and the decompression algorithm supports it, we can do decompression without
any intermediate heap buffers. Do not call unless you've checked
{@link #canDecompressViaByteBuff} first.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/HFileBlockDefaultDecodingContext.java