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

Package org.apache.hadoop.io.compress

# Class CompressionInputStream

java.lang.Object
java.io.InputStream
org.apache.hadoop.io.compress.CompressionInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `Seekable`, `IOStatisticsSource`

Direct Known Subclasses:
  `DecompressorStream`, `SplitCompressionInputStream`

@Public @Evolving public abstract class CompressionInputStream extends InputStream implements Seekable, IOStatisticsSource
A compression input stream.

Implementations are assumed to be buffered. This permits clients to reposition the underlying input stream then call `resetState()`, without having to also synchronize client buffers.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final InputStream`
  `in`
  The input stream to be compressed.
  `protected long`
  `maxAvailableData`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `CompressionInputStream(InputStream in)`
  Create a compression input stream that reads the decompressed bytes from the given stream.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `IOStatistics`
  `getIOStatistics()`
  Return any IOStatistics provided by the underlying stream.
  `long`
  `getPos()`
  This method returns the current position in the stream.
  `abstract int`
  `read(byte[] b, int off, int len)`
  Read bytes from the stream.
  `abstract void`
  `resetState()`
  Reset the decompressor to its initial state and discard any buffered data, as the underlying stream may have been repositioned.
  `void`
  `seek(long pos)`
  This method is current not supported.
  `boolean`
  `seekToNewSource(long targetPos)`
  This method is current not supported.

  ### Methods inherited from class java.io.InputStream

  `available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### in

    protected final InputStream in
    The input stream to be compressed.

  - ### maxAvailableData

    protected long maxAvailableData

- ## Constructor Details

  - ### CompressionInputStream

    protected CompressionInputStream(InputStream in) throws IOException
    Create a compression input stream that reads the decompressed bytes from the given stream.
    Parameters:
      `in` - The input stream to be compressed.
    Throws:
      `IOException` - raised on errors performing I/O.

- ## Method Details

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Overrides:
      `close` in class `InputStream`
    Throws:
      `IOException`

  - ### getIOStatistics

    public IOStatistics getIOStatistics()
    Return any IOStatistics provided by the underlying stream.
    Specified by:
      `getIOStatistics` in interface `IOStatisticsSource`
    Returns:
      IO stats from the inner stream.

  - ### read

    public abstract int read(byte[] b, int off, int len) throws IOException
    Read bytes from the stream. Made abstract to prevent leakage to underlying stream.
    Overrides:
      `read` in class `InputStream`
    Throws:
      `IOException`

  - ### resetState

    public abstract void resetState() throws IOException
    Reset the decompressor to its initial state and discard any buffered data, as the underlying stream may have been repositioned.
    Throws:
      `IOException` - raised on errors performing I/O.

  - ### getPos

    public long getPos() throws IOException
    This method returns the current position in the stream.
    Specified by:
      `getPos` in interface `Seekable`
    Returns:
      Current position in stream as a long
    Throws:
      `IOException` - raised on errors performing I/O.

  - ### seek

    public void seek(long pos) throws UnsupportedOperationException
    This method is current not supported.
    Specified by:
      `seek` in interface `Seekable`
    Parameters:
      `pos` - offset from the start of the file.
    Throws:
      `UnsupportedOperationException` - Unsupported Operation Exception.

  - ### seekToNewSource

    public boolean seekToNewSource(long targetPos) throws UnsupportedOperationException
    This method is current not supported.
    Specified by:
      `seekToNewSource` in interface `Seekable`
    Parameters:
      `targetPos` - target position.
    Returns:
      true if found a new source, false otherwise.
    Throws:
      `UnsupportedOperationException` - Unsupported Operation Exception.