Package com.linkedin.venice.compression
Class ReusableGzipOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.util.zip.DeflaterOutputStream
com.linkedin.venice.compression.ReusableGzipOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
This class implements a stream filter for writing compressed data in the GZIP file format. It's an adoption of
GZIPOutputStream
but with a notable difference regarding re-usability:
- Expose
reset()
to reset CRC32 and the deflater - Don't write the GZIP header upon construction but expose
writeHeader()
-
Field Summary
Fields inherited from class java.util.zip.DeflaterOutputStream
buf, def
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
-
Method Summary
Methods inherited from class java.util.zip.DeflaterOutputStream
close, deflate, flush, write
Methods inherited from class java.io.FilterOutputStream
write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
ReusableGzipOutputStream
-
-
Method Details
-
toByteArray
public byte[] toByteArray() -
write
Writes array of bytes to the compressed output stream. This method will block until all the bytes are written.- Overrides:
write
in classDeflaterOutputStream
- Parameters:
buf
- the data to be writtenoff
- the start offset of the datalen
- the length of the data- Throws:
IOException
- If an I/O error has occurred.
-
finish
Finishes writing compressed data to the output stream without closing the underlying stream. Use this method when applying multiple filters in succession to the same output stream.- Overrides:
finish
in classDeflaterOutputStream
- Throws:
IOException
- if an I/O error has occurred
-
writeHeader
- Throws:
IOException
-
reset
public void reset()
-