Package org.apache.hadoop.io.compress
Interface CompressionCodec
- All Known Subinterfaces:
DirectDecompressionCodec,SplittableCompressionCodec
- All Known Implementing Classes:
BZip2Codec,DefaultCodec,GzipCodec,PassthroughCodec
@Public
@Evolving
public interface CompressionCodec
This class encapsulates a streaming compression/decompression pair.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classorg.apache.hadoop.io.compress.CompressionCodec.Util -
Method Summary
Modifier and TypeMethodDescriptionCreate a newCompressorfor use by thisCompressionCodec.Create a newDecompressorfor use by thisCompressionCodec.Create aCompressionInputStreamthat will read from the given input stream.createInputStream(InputStream in, Decompressor decompressor) Create aCompressionInputStreamthat will read from the givenInputStreamwith the givenDecompressor.Create aCompressionOutputStreamthat will write to the givenOutputStream.createOutputStream(OutputStream out, Compressor compressor) Create aCompressionOutputStreamthat will write to the givenOutputStreamwith the givenCompressor.Class<? extends Compressor>Get the type ofCompressorneeded by thisCompressionCodec.Class<? extends Decompressor>Get the type ofDecompressorneeded by thisCompressionCodec.Get the default filename extension for this kind of compression.
-
Method Details
-
createOutputStream
Create aCompressionOutputStreamthat will write to the givenOutputStream.- Parameters:
out- the location for the final output stream- Returns:
- a stream the user can write uncompressed data to have it compressed
- Throws:
IOException- raised on errors performing I/O.
-
createOutputStream
CompressionOutputStream createOutputStream(OutputStream out, Compressor compressor) throws IOException Create aCompressionOutputStreamthat will write to the givenOutputStreamwith the givenCompressor.- Parameters:
out- the location for the final output streamcompressor- compressor to use- Returns:
- a stream the user can write uncompressed data to have it compressed
- Throws:
IOException- raised on errors performing I/O.
-
getCompressorType
Class<? extends Compressor> getCompressorType()Get the type ofCompressorneeded by thisCompressionCodec.- Returns:
- the type of compressor needed by this codec.
-
createCompressor
Compressor createCompressor()Create a newCompressorfor use by thisCompressionCodec.- Returns:
- a new compressor for use by this codec
-
createInputStream
Create aCompressionInputStreamthat will read from the given input stream.- Parameters:
in- the stream to read compressed bytes from- Returns:
- a stream to read uncompressed bytes from
- Throws:
IOException- raised on errors performing I/O.
-
createInputStream
CompressionInputStream createInputStream(InputStream in, Decompressor decompressor) throws IOException Create aCompressionInputStreamthat will read from the givenInputStreamwith the givenDecompressor.- Parameters:
in- the stream to read compressed bytes fromdecompressor- decompressor to use- Returns:
- a stream to read uncompressed bytes from
- Throws:
IOException- raised on errors performing I/O.
-
getDecompressorType
Class<? extends Decompressor> getDecompressorType()Get the type ofDecompressorneeded by thisCompressionCodec.- Returns:
- the type of decompressor needed by this codec.
-
createDecompressor
Decompressor createDecompressor()Create a newDecompressorfor use by thisCompressionCodec.- Returns:
- a new decompressor for use by this codec
-
getDefaultExtension
String getDefaultExtension()Get the default filename extension for this kind of compression.- Returns:
- the extension including the '.'
-