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 class
PigzOutputStream.Compressor
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BLOCK_SIZE
static int
DICT_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 void
close()
Closes this output stream and releases any system resources associated with the stream.void
flush()
Flushes this output stream and forces any buffered output bytes to be written out to the stream.long
getBytesCompressed()
Returns how many bytes has been written to this OutputStream.long
getBytesWritten()
Returns how many bytes has been written to the underlying OutputStream.void
write(byte[] b, int off, int len)
Writeslen
bytes from the specifiedbyte
array starting at offsetoff
to this output stream.void
write(int b)
Writes the specifiedbyte
to 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.IOException
Creates 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.IOException
Creates 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.IOException
Writes the specifiedbyte
to this output stream. Implements the abstract write method of OutputStream.- Overrides:
write
in 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.IOException
Writeslen
bytes from the specifiedbyte
array starting at offsetoff
to this output stream.- Overrides:
write
in 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.IOException
Flushes this output stream and forces any buffered output bytes to be written out to the stream. Theflush
method ofFilterOutputStream
calls theflush
method of its underlying output stream.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
close
public void close() throws java.io.IOException
Closes this output stream and releases any system resources associated with the stream.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in 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
-
-