@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_NULL_ON_SOME_PATH_EXCEPTION",
      justification = "No sure what findbugs wants but looks to me like no NPE")
  public static int getCompressedSize(Algorithm algo, Compressor compressor, byte[] inputBuffer,
    int offset, int length) throws IOException {

    // Create streams
    // Storing them so we can close them
    final IOUtils.NullOutputStream nullOutputStream = new IOUtils.NullOutputStream();
    final DataOutputStream compressedStream = new DataOutputStream(nullOutputStream);
    OutputStream compressingStream = null;

    try {
      if (compressor != null) {
        compressor.reset();
      }

      compressingStream = algo.createCompressionStream(compressedStream, compressor, 0);

      compressingStream.write(inputBuffer, offset, length);
      compressingStream.flush();

      return compressedStream.size();
    } finally {
      nullOutputStream.close();
      compressedStream.close();
      if (compressingStream != null) {
        compressingStream.close();
      }
    }
  }
Find the size of compressed data assuming that buffer will be compressed using given algorithm.
@param algo        compression algorithm
@param compressor  compressor already requested from codec
@param inputBuffer Array to be compressed.
@param offset      Offset to beginning of the data.
@param length      Length to be compressed.
@return Size of compressed data in bytes.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java