Package org.apache.hadoop.io.compress
Class BlockCompressorStream
java.lang.Object
java.io.OutputStream
org.apache.hadoop.io.compress.CompressionOutputStream
org.apache.hadoop.io.compress.CompressorStream
org.apache.hadoop.io.compress.BlockCompressorStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,org.apache.hadoop.fs.statistics.IOStatisticsSource
A
CompressorStream which works
with 'block-based' based compression algorithms, as opposed to
'stream-based' compression algorithms.
It should be noted that this wrapper does not guarantee that blocks will
be sized for the compressor. If the
Compressor requires buffering to
effect meaningful compression, it is responsible for it.-
Field Summary
Fields inherited from class org.apache.hadoop.io.compress.CompressorStream
buffer, closed, compressorFields inherited from class org.apache.hadoop.io.compress.CompressionOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionBlockCompressorStream(OutputStream out, Compressor compressor) Create aBlockCompressorStreamwith given output-stream and compressor.BlockCompressorStream(OutputStream out, Compressor compressor, int bufferSize, int compressionOverhead) Create aBlockCompressorStream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcompress()voidfinish()Finishes writing compressed data to the output stream without closing the underlying stream.voidwrite(byte[] b, int off, int len) Write the data provided to the compression codec, compressing no more than the buffer size less the compression overhead as specified during construction for each block.Methods inherited from class org.apache.hadoop.io.compress.CompressorStream
close, resetState, writeMethods inherited from class org.apache.hadoop.io.compress.CompressionOutputStream
flush, getIOStatisticsMethods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
BlockCompressorStream
public BlockCompressorStream(OutputStream out, Compressor compressor, int bufferSize, int compressionOverhead) Create aBlockCompressorStream.- Parameters:
out- streamcompressor- compressor to be usedbufferSize- size of buffercompressionOverhead- maximum 'overhead' of the compression algorithm with given bufferSize
-
BlockCompressorStream
Create aBlockCompressorStreamwith given output-stream and compressor. Use default of 512 as bufferSize and compressionOverhead of (1% of bufferSize + 12 bytes) = 18 bytes (zlib algorithm).- Parameters:
out- streamcompressor- compressor to be used
-
-
Method Details
-
write
Write the data provided to the compression codec, compressing no more than the buffer size less the compression overhead as specified during construction for each block. Each block contains the uncompressed length for the block, followed by one or more length-prefixed blocks of compressed data.- Overrides:
writein classCompressorStream- Throws:
IOException
-
finish
Description copied from class:CompressionOutputStreamFinishes writing compressed data to the output stream without closing the underlying stream.- Overrides:
finishin classCompressorStream- Throws:
IOException- raised on errors performing I/O.
-
compress
- Overrides:
compressin classCompressorStream- Throws:
IOException
-