CompressionCodec (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.io.compress, interface: CompressionCodec

Package org.apache.hadoop.io.compress

# Interface CompressionCodec

All Known Subinterfaces:
  `DirectDecompressionCodec`, `SplittableCompressionCodec`

All Known Implementing Classes:
  `BZip2Codec`, `DefaultCodec`, `DeflateCodec`, `GzipCodec`, `Lz4Codec`, `PassthroughCodec`, `SnappyCodec`, `ZStandardCodec`

@Public @Evolving public interface CompressionCodec
This class encapsulates a streaming compression/decompression pair.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `CompressionCodec.Util`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Compressor`
  `createCompressor()`
  Create a new `Compressor` for use by this `CompressionCodec`.
  `Decompressor`
  `createDecompressor()`
  Create a new `Decompressor` for use by this `CompressionCodec`.
  `CompressionInputStream`
  `createInputStream(InputStream in)`
  Create a `CompressionInputStream` that will read from the given input stream.
  `CompressionInputStream`
  `createInputStream(InputStream in, Decompressor decompressor)`
  Create a `CompressionInputStream` that will read from the given `InputStream` with the given `Decompressor`.
  `CompressionOutputStream`
  `createOutputStream(OutputStream out)`
  Create a `CompressionOutputStream` that will write to the given `OutputStream`.
  `CompressionOutputStream`
  `createOutputStream(OutputStream out, Compressor compressor)`
  Create a `CompressionOutputStream` that will write to the given `OutputStream` with the given `Compressor`.
  `Class<? extends Compressor>`
  `getCompressorType()`
  Get the type of `Compressor` needed by this `CompressionCodec`.
  `Class<? extends Decompressor>`
  `getDecompressorType()`
  Get the type of `Decompressor` needed by this `CompressionCodec`.
  `String`
  `getDefaultExtension()`
  Get the default filename extension for this kind of compression.

- ## Method Details

  - ### createOutputStream

    CompressionOutputStream createOutputStream(OutputStream out) throws IOException
    Create a `CompressionOutputStream` that will write to the given `OutputStream`.
    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 a `CompressionOutputStream` that will write to the given `OutputStream` with the given `Compressor`.
    Parameters:
      `out` - the location for the final output stream
      `compressor` - 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 of `Compressor` needed by this `CompressionCodec`.
    Returns:
      the type of compressor needed by this codec.

  - ### createCompressor

    Compressor createCompressor()
    Create a new `Compressor` for use by this `CompressionCodec`.
    Returns:
      a new compressor for use by this codec

  - ### createInputStream

    CompressionInputStream createInputStream(InputStream in) throws IOException
    Create a `CompressionInputStream` that 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 a `CompressionInputStream` that will read from the given `InputStream` with the given `Decompressor`.
    Parameters:
      `in` - the stream to read compressed bytes from
      `decompressor` - 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 of `Decompressor` needed by this `CompressionCodec`.
    Returns:
      the type of decompressor needed by this codec.

  - ### createDecompressor

    Decompressor createDecompressor()
    Create a new `Decompressor` for use by this `CompressionCodec`.
    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 '.'