in src/main/java/com/hadoop/compression/lzo/LzoCodec.java [114:149]
public CompressionOutputStream createOutputStream(OutputStream out,
Compressor compressor) throws IOException {
// Ensure native-lzo library is loaded & initialized
if (!isNativeLzoLoaded(conf)) {
throw new RuntimeException("native-lzo library not available");
}
/**
* <b>https://www.oberhumer.com/opensource/lzo/lzofaq.php</b>
*
* How much can my data expand during compression ?
* ================================================
* LZO will expand incompressible data by a little amount.
* I still haven't computed the exact values, but I suggest using
* these formulas for a worst-case expansion calculation:
*
* Algorithm LZO1, LZO1A, LZO1B, LZO1C, LZO1F, LZO1X, LZO1Y, LZO1Z:
* ----------------------------------------------------------------
* output_block_size = input_block_size + (input_block_size / 16) + 64 + 3
*
* This is about 106% for a large block size.
*
* Algorithm LZO2A:
* ----------------
* output_block_size = input_block_size + (input_block_size / 8) + 128 + 3
*/
// Create the lzo output-stream
LzoCompressor.CompressionStrategy strategy = getCompressionStrategy(conf);
int bufferSize = getBufferSize(conf);
int compressionOverhead = strategy.name().contains("LZO1") ?
(bufferSize >> 4) + 64 + 3 : (bufferSize >> 3) + 128 + 3;
return new BlockCompressorStream(out, compressor, bufferSize,
compressionOverhead);
}