code: private void writeCompressed(ByteBuffer buffer)
              throws IOException
      {
  
          final byte[] input = buffer.array();
          final int length = buffer.remaining();
  
          // crc is based on the user supplied input data
          final int crc32c = maskedCrc32c(input, 0, length);
  
          directInputBuffer.clear();
          directInputBuffer.put(buffer);
          directInputBuffer.flip();
  
          outputBuffer.clear();
          Snappy.compress(directInputBuffer, outputBuffer);
  
          final int compressedLength = outputBuffer.remaining();
  
          // only use the compressed data if compression ratio is <= the
          // minCompressonRatio
          if (((double) compressedLength / (double) length) <= minCompressionRatio) {
              writeBlock(out, outputBuffer, true, crc32c);
          }
          else {
              // otherwise use the uncompressed data.
              buffer.flip();
              writeBlock(out, buffer, false, crc32c);
          }
      }
docs: {@link SnappyFramed#maskedCrc32c(byte[], int, int)} the crc, compresses
  the data, determines if the compression ratio is acceptable and calls
  {@link #writeBlock(java.nio.channels.WritableByteChannel, java.nio.ByteBuffer, boolean, int)} to
  actually write the frame.
  
  @param buffer
  @throws IOException