Package com.linkedin.alpini.io
Class PigzOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.linkedin.alpini.io.PigzOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class PigzOutputStream extends java.io.FilterOutputStream
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPigzOutputStream.Compressor
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_BLOCK_SIZEstatic intDICT_LENGTH
-
Constructor Summary
Constructors Constructor Description PigzOutputStream(int compressionLevel, java.util.concurrent.Executor executor, int concurrency, java.io.OutputStream out)Creates a new output stream with the specified compression level, concurrency and a default block size.PigzOutputStream(int compressionLevel, java.util.concurrent.Executor executor, int concurrency, java.io.OutputStream out, int blockSize)Creates a new output stream with the specified compression level, concurrency and block size.PigzOutputStream(int compressionLevel, java.util.concurrent.Executor executor, int concurrency, java.io.OutputStream out, int blockSize, java.util.function.Function<PigzOutputStream,PigzOutputStream.Compressor> compressorSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this output stream and releases any system resources associated with the stream.voidflush()Flushes this output stream and forces any buffered output bytes to be written out to the stream.longgetBytesCompressed()Returns how many bytes has been written to this OutputStream.longgetBytesWritten()Returns how many bytes has been written to the underlying OutputStream.voidwrite(byte[] b, int off, int len)Writeslenbytes from the specifiedbytearray starting at offsetoffto this output stream.voidwrite(int b)Writes the specifiedbyteto this output stream.
-
-
-
Field Detail
-
DICT_LENGTH
public static final int DICT_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PigzOutputStream
public PigzOutputStream(int compressionLevel, @Nonnull java.util.concurrent.Executor executor, int concurrency, @Nonnull @WillCloseWhenClosed java.io.OutputStream out) throws java.io.IOExceptionCreates a new output stream with the specified compression level, concurrency and a default block size.- Parameters:
compressionLevel- gzip compression level, 1..9executor- executor to run threads.concurrency- maximum number of worker threads.out- the output stream.- Throws:
java.io.IOException- if an I/O error has occurred.
-
PigzOutputStream
public PigzOutputStream(int compressionLevel, @Nonnull java.util.concurrent.Executor executor, int concurrency, @Nonnull @WillCloseWhenClosed java.io.OutputStream out, int blockSize) throws java.io.IOExceptionCreates a new output stream with the specified compression level, concurrency and block size.- Parameters:
compressionLevel- gzip compression level, 1..9executor- executor to run threads.concurrency- maximum number of worker threads.out- the output stream.blockSize- compressor block size- Throws:
java.io.IOException- if an I/O error has occurred.
-
PigzOutputStream
public PigzOutputStream(int compressionLevel, @Nonnull java.util.concurrent.Executor executor, int concurrency, @Nonnull @WillCloseWhenClosed java.io.OutputStream out, int blockSize, @Nonnull java.util.function.Function<PigzOutputStream,PigzOutputStream.Compressor> compressorSupplier) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOExceptionWrites the specifiedbyteto this output stream. Implements the abstract write method of OutputStream.- Overrides:
writein classjava.io.FilterOutputStream- Parameters:
b- thebyte.- Throws:
java.io.IOException- if an I/O error occurs.
-
write
public void write(@Nonnull byte[] b, int off, int len) throws java.io.IOExceptionWriteslenbytes from the specifiedbytearray starting at offsetoffto this output stream.- Overrides:
writein classjava.io.FilterOutputStream- Parameters:
b- the data.off- the start offset in the data.len- the number of bytes to write.- Throws:
java.io.IOException- if an I/O error occurs.- See Also:
FilterOutputStream.write(int)
-
flush
public void flush() throws java.io.IOExceptionFlushes this output stream and forces any buffered output bytes to be written out to the stream. Theflushmethod ofFilterOutputStreamcalls theflushmethod of its underlying output stream.- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.FilterOutputStream- Throws:
java.io.IOException- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
close
public void close() throws java.io.IOExceptionCloses this output stream and releases any system resources associated with the stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterOutputStream- Throws:
java.io.IOException- if an I/O error occurs.- See Also:
FilterOutputStream.flush(),FilterOutputStream.out
-
getBytesCompressed
public long getBytesCompressed()
Returns how many bytes has been written to this OutputStream.- Returns:
- number of bytes
-
getBytesWritten
public long getBytesWritten()
Returns how many bytes has been written to the underlying OutputStream.- Returns:
- number of bytes
-
-