public class PLZFOutputStream
extends java.io.FilterOutputStream
implements java.nio.channels.WritableByteChannel
OutputStream
implementation that will compress
output using LZF compression algorithm, given uncompressed input
to write. Its counterpart is LZFInputStream
; although
in some ways LZFCompressingInputStream
can be seen
as the opposite.
This class uses a parallel implementation to make use of all available cores, modulo system load.
LZFInputStream
,
LZFCompressingInputStream
,
LZFOutputStream
Modifier and Type | Field and Description |
---|---|
protected byte[] |
_outputBuffer |
protected boolean |
_outputStreamClosed
Flag that indicates if we have already called '_outputStream.close()'
(to avoid calling it multiple times)
|
protected int |
_position |
private BlockManager |
blockManager |
private java.util.concurrent.ExecutorService |
compressExecutor |
private static int |
DEFAULT_OUTPUT_BUFFER_SIZE |
(package private) java.lang.Exception |
writeException |
private java.util.concurrent.ExecutorService |
writeExecutor |
Modifier | Constructor and Description |
---|---|
|
PLZFOutputStream(java.io.OutputStream outputStream) |
protected |
PLZFOutputStream(java.io.OutputStream outputStream,
int nThreads) |
protected |
PLZFOutputStream(java.io.OutputStream outputStream,
int bufferSize,
int nThreads) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkNotClosed() |
protected void |
checkWriteException() |
void |
close() |
void |
flush()
This
flush method does nothing. |
protected static int |
getNThreads() |
java.io.OutputStream |
getUnderlyingOutputStream()
Method that can be used to find underlying
OutputStream that
we write encoded LZF encoded data into, after compressing it. |
boolean |
isOpen() |
void |
write(byte[] buffer,
int offset,
int length) |
int |
write(java.nio.ByteBuffer src) |
void |
write(java.nio.channels.FileChannel in) |
void |
write(java.io.InputStream in) |
void |
write(int singleByte)
WARNING: using this method will lead to very poor performance!
|
protected void |
writeCompressedBlock()
Compress and write the current block to the OutputStream
|
private static final int DEFAULT_OUTPUT_BUFFER_SIZE
protected byte[] _outputBuffer
protected int _position
protected boolean _outputStreamClosed
private BlockManager blockManager
private final java.util.concurrent.ExecutorService compressExecutor
private final java.util.concurrent.ExecutorService writeExecutor
volatile java.lang.Exception writeException
public PLZFOutputStream(java.io.OutputStream outputStream)
protected PLZFOutputStream(java.io.OutputStream outputStream, int nThreads)
protected PLZFOutputStream(java.io.OutputStream outputStream, int bufferSize, int nThreads)
protected static int getNThreads()
public void write(int singleByte) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void write(byte[] buffer, int offset, int length) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void write(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public void write(java.nio.channels.FileChannel in) throws java.io.IOException
java.io.IOException
public int write(java.nio.ByteBuffer src) throws java.io.IOException
write
in interface java.nio.channels.WritableByteChannel
java.io.IOException
public void flush() throws java.io.IOException
flush
method does nothing.flush
in interface java.io.Flushable
flush
in class java.io.FilterOutputStream
java.io.IOException
public boolean isOpen()
isOpen
in interface java.nio.channels.Channel
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface java.nio.channels.Channel
close
in class java.io.FilterOutputStream
java.io.IOException
public java.io.OutputStream getUnderlyingOutputStream()
OutputStream
that
we write encoded LZF encoded data into, after compressing it.
Will never return null; although underlying stream may be closed
(if this stream has been closed).protected void writeCompressedBlock() throws java.io.IOException
java.io.IOException
protected void checkWriteException() throws java.io.IOException
java.io.IOException
protected void checkNotClosed() throws java.io.IOException
java.io.IOException