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:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class ReusableGzipOutputStream extends java.util.zip.DeflaterOutputStream
This class implements a stream filter for writing compressed data in the GZIP file format. It's an adoption ofGZIPOutputStream
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()
-
-
Constructor Summary
Constructors Constructor Description ReusableGzipOutputStream(java.io.ByteArrayOutputStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finish()
Finishes writing compressed data to the output stream without closing the underlying stream.void
reset()
byte[]
toByteArray()
void
write(byte[] buf, int off, int len)
Writes array of bytes to the compressed output stream.void
writeHeader()
-
-
-
Method Detail
-
toByteArray
public byte[] toByteArray()
-
write
public void write(byte[] buf, int off, int len) throws java.io.IOException
Writes array of bytes to the compressed output stream. This method will block until all the bytes are written.- Overrides:
write
in classjava.util.zip.DeflaterOutputStream
- Parameters:
buf
- the data to be writtenoff
- the start offset of the datalen
- the length of the data- Throws:
java.io.IOException
- If an I/O error has occurred.
-
finish
public void finish() throws java.io.IOException
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 classjava.util.zip.DeflaterOutputStream
- Throws:
java.io.IOException
- if an I/O error has occurred
-
writeHeader
public void writeHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
reset
public void reset()
-
-