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 LZ77Compressor
private final Deque<byte[]>
private boolean
private static final int
private static final int
private final byte[]
private final OutputStream
private 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 void
private void
private void
private void
private void
void
close()
static Parameters.Builder
Returns a builder correctly configured for the LZ4 algorithm.private byte[]
expand
(int offset, int length) private void
expandFromList
(byte[] expanded, int offset, int length) void
finish()
Compresses all remaining data and writes it to the stream, doesn't close the underlying stream.void
prefill
(byte[] data, int off, int len) Adds some initial data to fill the window with.private void
private void
recordLiteral
(byte[] b) private void
void
write
(byte[] data, int off, int len) void
write
(int b) writeBlocksAndReturnUnfinishedPair
(int length) private void
private void
writeWritablePairs
(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- Throws:
IOException
- if reading fails
-
BlockLZ4CompressorOutputStream
Creates a new LZ4 output stream.- Parameters:
os
- An OutputStream to read compressed data fromparams
- The parameters to use for LZ77 compression.- Throws:
IOException
- if reading fails
-
-
Method Details
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
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:
-
addLiteralBlock
- Throws:
IOException
-
addBackReference
- Throws:
IOException
-
writeBlocksAndReturnUnfinishedPair
private BlockLZ4CompressorOutputStream.Pair writeBlocksAndReturnUnfinishedPair(int length) throws IOException - Throws:
IOException
-
recordLiteral
private void recordLiteral(byte[] b) -
clearUnusedBlocksAndPairs
private void clearUnusedBlocksAndPairs() -
clearUnusedBlocks
private void clearUnusedBlocks() -
recordBackReference
-
expand
private byte[] expand(int offset, int length) -
expandFromList
private void expandFromList(byte[] expanded, int offset, int length) -
clearUnusedPairs
private void clearUnusedPairs() -
writeFinalLiteralBlock
- Throws:
IOException
-
writeWritablePairs
- Throws:
IOException
-
rewriteLastPairs
private void rewriteLastPairs() -
createParameterBuilder
Returns a builder correctly configured for the LZ4 algorithm.- Returns:
- a builder correctly configured for the LZ4 algorithm
-