Class CompressionOutputStream

java.lang.Object
java.io.OutputStream
org.apache.hadoop.io.compress.CompressionOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, org.apache.hadoop.fs.statistics.IOStatisticsSource
Direct Known Subclasses:
CompressorStream

@Public @Evolving public abstract class CompressionOutputStream extends OutputStream implements org.apache.hadoop.fs.statistics.IOStatisticsSource
A compression output stream.
  • Field Details

    • out

      protected final OutputStream out
      The output stream to be compressed.
  • Constructor Details

    • CompressionOutputStream

      protected CompressionOutputStream(OutputStream out)
      Create a compression output stream that writes the compressed bytes to the given stream.
      Parameters:
      out - out.
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • write

      public abstract void write(byte[] b, int off, int len) throws IOException
      Write compressed bytes to the stream. Made abstract to prevent leakage to underlying stream.
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • finish

      public abstract void finish() throws IOException
      Finishes writing compressed data to the output stream without closing the underlying stream.
      Throws:
      IOException - raised on errors performing I/O.
    • resetState

      public abstract void resetState() throws IOException
      Reset the compression to the initial state. Does not reset the underlying stream.
      Throws:
      IOException - raised on errors performing I/O.
    • getIOStatistics

      public IOStatistics getIOStatistics()
      Return any IOStatistics provided by the underlying stream.
      Specified by:
      getIOStatistics in interface org.apache.hadoop.fs.statistics.IOStatisticsSource
      Returns:
      IO stats from the inner stream.