Class BlockLZ4CompressorOutputStream
java.lang.Object
java.io.OutputStream
org.apache.commons.compress.compressors.CompressorOutputStream
org.apache.commons.compress.compressors.lz4.BlockLZ4CompressorOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
CompressorOutputStream for the LZ4 block format.
- Since:
- 1.14
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LZ77Compressorprivate final Deque<byte[]> private booleanprivate static final intprivate static final intprivate final byte[]private final OutputStreamprivate final Deque<BlockLZ4CompressorOutputStream.Pair> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new LZ4 output stream.BlockLZ4CompressorOutputStream(OutputStream os, Parameters params) Creates a new LZ4 output stream. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidprivate voidprivate voidprivate voidvoidclose()static Parameters.BuilderReturns a builder correctly configured for the LZ4 algorithm.private byte[]expand(int offset, int length) private voidexpandFromList(byte[] expanded, int offset, int length) voidfinish()Compresses all remaining data and writes it to the stream, doesn't close the underlying stream.voidprefill(byte[] data, int off, int len) Adds some initial data to fill the window with.private voidprivate voidrecordLiteral(byte[] b) private voidvoidwrite(byte[] data, int off, int len) voidwrite(int b) writeBlocksAndReturnUnfinishedPair(int length) private voidprivate voidwriteWritablePairs(int lengthOfBlocksAfterLastPair) Methods inherited from class java.io.OutputStream
flush, write
-
Field Details
-
MIN_BACK_REFERENCE_LENGTH
private static final int MIN_BACK_REFERENCE_LENGTH- See Also:
-
MIN_OFFSET_OF_LAST_BACK_REFERENCE
private static final int MIN_OFFSET_OF_LAST_BACK_REFERENCE- See Also:
-
compressor
-
os
-
oneByte
private final byte[] oneByte -
finished
private boolean finished -
pairs
-
expandedBlocks
-
-
Constructor Details
-
BlockLZ4CompressorOutputStream
Creates a new LZ4 output stream.- Parameters:
os- An OutputStream to read compressed data from
-
BlockLZ4CompressorOutputStream
Creates a new LZ4 output stream.- Parameters:
os- An OutputStream to read compressed data fromparams- The parameters to use for LZ77 compression.
-
-
Method Details
-
createParameterBuilder
Returns a builder correctly configured for the LZ4 algorithm.- Returns:
- a builder correctly configured for the LZ4 algorithm
-
addBackReference
- Throws:
IOException
-
addLiteralBlock
- Throws:
IOException
-
clearUnusedBlocks
private void clearUnusedBlocks() -
clearUnusedBlocksAndPairs
private void clearUnusedBlocksAndPairs() -
clearUnusedPairs
private void clearUnusedPairs() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
expand
private byte[] expand(int offset, int length) -
expandFromList
private void expandFromList(byte[] expanded, int offset, int length) -
finish
Compresses all remaining data and writes it to the stream, doesn't close the underlying stream.- Throws:
IOException- if an error occurs
-
prefill
public void prefill(byte[] data, int off, int len) Adds some initial data to fill the window with.- Parameters:
data- the data to fill the window with.off- offset of real data into the arraylen- amount of data- Throws:
IllegalStateException- if the stream has already started to write data- See Also:
-
recordBackReference
-
recordLiteral
private void recordLiteral(byte[] b) -
rewriteLastPairs
private void rewriteLastPairs() -
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
writeBlocksAndReturnUnfinishedPair
private BlockLZ4CompressorOutputStream.Pair writeBlocksAndReturnUnfinishedPair(int length) throws IOException - Throws:
IOException
-
writeFinalLiteralBlock
- Throws:
IOException
-
writeWritablePairs
- Throws:
IOException
-