Package org.apache.nifi.remote.io
Class CompressionOutputStream
java.lang.Object
java.io.OutputStream
org.apache.nifi.remote.io.CompressionOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]private intprivate final byte[]private booleanstatic final intstatic final intprivate final Deflaterstatic final intprivate final OutputStreamstatic final byte[] -
Constructor Summary
ConstructorsConstructorDescriptionCompressionOutputStream(OutputStream outStream) CompressionOutputStream(OutputStream outStream, int bufferSize) CompressionOutputStream(OutputStream outStream, int bufferSize, int level, int strategy) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanvoidclose()Flushes remaining buffer and callsDeflater.end()to free acquired memory to prevent OutOfMemory error.protected voidCompresses the currently buffered chunk of data and sends it to the output streamvoidflush()voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) private voidwriteChunkHeader(int compressedBytes) private voidwriteInt(OutputStream out, int val) Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
SYNC_BYTES
public static final byte[] SYNC_BYTES -
DEFAULT_COMPRESSION_LEVEL
public static final int DEFAULT_COMPRESSION_LEVEL- See Also:
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
MIN_BUFFER_SIZE
public static final int MIN_BUFFER_SIZE- See Also:
-
out
-
deflater
-
buffer
private final byte[] buffer -
compressed
private final byte[] compressed -
bufferIndex
private int bufferIndex -
dataWritten
private boolean dataWritten
-
-
Constructor Details
-
CompressionOutputStream
-
CompressionOutputStream
-
CompressionOutputStream
-
-
Method Details
-
compressAndWrite
Compresses the currently buffered chunk of data and sends it to the output stream- Throws:
IOException- if issues occur writing to stream
-
writeChunkHeader
- Throws:
IOException
-
writeInt
- Throws:
IOException
-
bufferFull
protected boolean bufferFull() -
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
Flushes remaining buffer and callsDeflater.end()to free acquired memory to prevent OutOfMemory error.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- for any issues closing underlying stream
-