public int getDecompressBufferSize(ByteBuffer compressedBuffer) throws CompressionException {
    Utils.checkNotNullOrEmpty(compressedBuffer, "compressedBuffer cannot be null or empty.");
    if (compressedBuffer.remaining() < VERSION_AND_NAME_LENGTH_AND_ORIGINAL_SIZE_SIZE) {
      throw new IllegalArgumentException(
          "compressedDataSize of " + compressedBuffer.remaining() + " bytes is too small.");
    }

    // Check version.  For now, only version 1 is supported.  Modify this code when more version added.
    compressedBuffer.mark();
    try {
      byte version = compressedBuffer.get();
      if (version != 1) {
        // It throws CompressionException to indicate internal error instead of illegal argument because
        // the compressed buffer contains a version that is not supported.  It's probably a code problem, not data problem.
        // Modify this condition as new versions are added.
        throw new CompressionException("compressedBuffer has unsupported version " + version);
      }

      // Assume the algorithm name is correct, so skip the name verification.
      // Original size offset = version (1 byte) + name size (1 byte) + name (N byte) + data size (4 bytes);
      int nameSizeInBytes = compressedBuffer.get();
      int dataSizePosition = compressedBuffer.position() + nameSizeInBytes;
      if (dataSizePosition + 4 >= compressedBuffer.limit()) {
        throw new IllegalArgumentException("compressedBuffer too small and does not contain original data size.");
      }
      compressedBuffer.position(dataSizePosition);
      return compressedBuffer.getInt();
    } finally {
      compressedBuffer.reset();
    }
  }
Get the original data size stored inside the compressed buffer.  The compressed buffer contains version,
algorithm name, original data size, and compressed data.  The compressedBuffer indexes will not be changed.
@param compressedBuffer The compressed buffer.
@return The size of original data.
ambry-commons/src/main/java/com/github/ambry/compression/BaseCompression.java