Package org.apache.hadoop.io.compress
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final OutputStreamThe output stream to be compressed. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate a compression output stream that writes the compressed bytes to the given stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()abstract voidfinish()Finishes writing compressed data to the output stream without closing the underlying stream.voidflush()Return any IOStatistics provided by the underlying stream.abstract voidReset the compression to the initial state.abstract voidwrite(byte[] b, int off, int len) Write compressed bytes to the stream.Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Field Details
-
out
The output stream to be compressed.
-
-
Constructor Details
-
CompressionOutputStream
Create a compression output stream that writes the compressed bytes to the given stream.- Parameters:
out- out.
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
write
Write compressed bytes to the stream. Made abstract to prevent leakage to underlying stream.- Overrides:
writein classOutputStream- Throws:
IOException
-
finish
Finishes writing compressed data to the output stream without closing the underlying stream.- Throws:
IOException- raised on errors performing I/O.
-
resetState
Reset the compression to the initial state. Does not reset the underlying stream.- Throws:
IOException- raised on errors performing I/O.
-
getIOStatistics
Return any IOStatistics provided by the underlying stream.- Specified by:
getIOStatisticsin interfaceorg.apache.hadoop.fs.statistics.IOStatisticsSource- Returns:
- IO stats from the inner stream.
-