Package com.ning.compress.lzf.parallel
Class PLZFOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.ning.compress.lzf.parallel.PLZFOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,Channel
,WritableByteChannel
Decorator
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
protected boolean
Flag that indicates if we have already called '_outputStream.close()' (to avoid calling it multiple times)protected int
private BlockManager
private final ExecutorService
private static final int
(package private) Exception
private final ExecutorService
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsModifierConstructorDescriptionPLZFOutputStream
(OutputStream outputStream) protected
PLZFOutputStream
(OutputStream outputStream, int nThreads) protected
PLZFOutputStream
(OutputStream outputStream, int bufferSize, int nThreads) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
void
close()
void
flush()
Thisflush
method does nothing.protected static int
Method that can be used to find underlyingOutputStream
that we write encoded LZF encoded data into, after compressing it.boolean
isOpen()
void
write
(byte[] buffer, int offset, int length) void
write
(int singleByte) WARNING: using this method will lead to very poor performance!void
write
(InputStream in) int
write
(ByteBuffer src) void
write
(FileChannel in) protected void
Compress and write the current block to the OutputStreamMethods inherited from class java.io.FilterOutputStream
write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
DEFAULT_OUTPUT_BUFFER_SIZE
private static final int DEFAULT_OUTPUT_BUFFER_SIZE- See Also:
-
_outputBuffer
protected byte[] _outputBuffer -
_position
protected int _position -
_outputStreamClosed
protected boolean _outputStreamClosedFlag that indicates if we have already called '_outputStream.close()' (to avoid calling it multiple times) -
blockManager
-
compressExecutor
-
writeExecutor
-
writeException
-
-
Constructor Details
-
PLZFOutputStream
-
PLZFOutputStream
-
PLZFOutputStream
-
-
Method Details
-
getNThreads
protected static int getNThreads() -
write
WARNING: using this method will lead to very poor performance!- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Specified by:
write
in interfaceWritableByteChannel
- Throws:
IOException
-
flush
Thisflush
method does nothing.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterOutputStream
- Throws:
IOException
-
isOpen
public boolean isOpen() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
getUnderlyingOutputStream
Method that can be used to find underlyingOutputStream
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). -
writeCompressedBlock
Compress and write the current block to the OutputStream- Throws:
IOException
-
checkWriteException
- Throws:
IOException
-
checkNotClosed
- Throws:
IOException
-