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 booleanFlag that indicates if we have already called '_outputStream.close()' (to avoid calling it multiple times)protected intprivate BlockManagerprivate final ExecutorServiceprivate static final int(package private) Exceptionprivate final ExecutorServiceFields inherited from class FilterOutputStream
out -
Constructor Summary
ConstructorsModifierConstructorDescriptionPLZFOutputStream(OutputStream outputStream) protectedPLZFOutputStream(OutputStream outputStream, int nThreads) protectedPLZFOutputStream(OutputStream outputStream, int bufferSize, int nThreads) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidvoidclose()voidflush()Thisflushmethod does nothing.protected static intMethod that can be used to find underlyingOutputStreamthat we write encoded LZF encoded data into, after compressing it.booleanisOpen()voidwrite(byte[] buffer, int offset, int length) voidwrite(int singleByte) WARNING: using this method will lead to very poor performance!voidwrite(InputStream in) intwrite(ByteBuffer src) voidwrite(FileChannel in) protected voidCompress and write the current block to the OutputStreamMethods inherited from class FilterOutputStream
writeMethods inherited from class 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:
writein classFilterOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
flush
Thisflushmethod does nothing.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFilterOutputStream- Throws:
IOException
-
isOpen
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
getUnderlyingOutputStream
Method that can be used to find underlyingOutputStreamthat 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
-