Class FramedLZ4CompressorOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.commons.compress.compressors.CompressorOutputStream
-
- org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class FramedLZ4CompressorOutputStream extends CompressorOutputStream
CompressorOutputStream for the LZ4 frame format.Based on the "spec" in the version "1.5.1 (31/03/2015)"
- Since:
- 1.14
- See Also:
- LZ4 Frame Format Description
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFramedLZ4CompressorOutputStream.BlockSizeThe block sizes supported by the format.static classFramedLZ4CompressorOutputStream.ParametersParameters of the LZ4 frame format.
-
Field Summary
Fields Modifier and Type Field Description private byte[]blockDataprivate byte[]blockDependencyBufferprivate XXHash32blockHashprivate intcollectedBlockDependencyBytesprivate XXHash32contentHashprivate intcurrentIndexprivate static byte[]END_MARKprivate booleanfinishedprivate byte[]oneByteprivate java.io.OutputStreamoutprivate FramedLZ4CompressorOutputStream.Parametersparams
-
Constructor Summary
Constructors Constructor Description FramedLZ4CompressorOutputStream(java.io.OutputStream out)Constructs a new output stream that compresses data using the LZ4 frame format using the default block size of 4MB.FramedLZ4CompressorOutputStream(java.io.OutputStream out, FramedLZ4CompressorOutputStream.Parameters params)Constructs a new output stream that compresses data using the LZ4 frame format using the given block size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendToBlockDependencyBuffer(byte[] b, int off, int len)voidclose()voidfinish()Compresses all remaining data and writes it to the stream, doesn't close the underlying stream.private voidflushBlock()voidwrite(byte[] data, int off, int len)voidwrite(int b)private voidwriteFrameDescriptor()private voidwriteTrailer()
-
-
-
Field Detail
-
END_MARK
private static final byte[] END_MARK
-
oneByte
private final byte[] oneByte
-
blockData
private final byte[] blockData
-
out
private final java.io.OutputStream out
-
params
private final FramedLZ4CompressorOutputStream.Parameters params
-
finished
private boolean finished
-
currentIndex
private int currentIndex
-
contentHash
private final XXHash32 contentHash
-
blockHash
private final XXHash32 blockHash
-
blockDependencyBuffer
private final byte[] blockDependencyBuffer
-
collectedBlockDependencyBytes
private int collectedBlockDependencyBytes
-
-
Constructor Detail
-
FramedLZ4CompressorOutputStream
public FramedLZ4CompressorOutputStream(java.io.OutputStream out) throws java.io.IOExceptionConstructs a new output stream that compresses data using the LZ4 frame format using the default block size of 4MB.- Parameters:
out- the OutputStream to which to write the compressed data- Throws:
java.io.IOException- if writing the signature fails
-
FramedLZ4CompressorOutputStream
public FramedLZ4CompressorOutputStream(java.io.OutputStream out, FramedLZ4CompressorOutputStream.Parameters params) throws java.io.IOExceptionConstructs a new output stream that compresses data using the LZ4 frame format using the given block size.- Parameters:
out- the OutputStream to which to write the compressed dataparams- the parameters to use- Throws:
java.io.IOException- if writing the signature fails
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] data, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
finish
public void finish() throws java.io.IOExceptionCompresses all remaining data and writes it to the stream, doesn't close the underlying stream.- Throws:
java.io.IOException- if an error occurs
-
writeFrameDescriptor
private void writeFrameDescriptor() throws java.io.IOException- Throws:
java.io.IOException
-
flushBlock
private void flushBlock() throws java.io.IOException- Throws:
java.io.IOException
-
writeTrailer
private void writeTrailer() throws java.io.IOException- Throws:
java.io.IOException
-
appendToBlockDependencyBuffer
private void appendToBlockDependencyBuffer(byte[] b, int off, int len)
-
-