Package net.jpountz.lz4
Class LZ4FrameInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
net.jpountz.lz4.LZ4FrameInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Implementation of the v1.5.1 LZ4 Frame format. This class is NOT thread safe.
Not Supported:
- Dependent blocks
- Legacy streams
Originally based on kafka's KafkaLZ4BlockInputStream.
- See Also:
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newInputStreamthat will decompress data using fastest instances ofLZ4SafeDecompressorandXXHash32.LZ4FrameInputStream(InputStream in, boolean readSingleFrame) Creates a newInputStreamthat will decompress data using fastest instances ofLZ4SafeDecompressorandXXHash32.LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum) Creates a newInputStreamthat will decompress data using the LZ4 algorithm.LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum, boolean readSingleFrame) Creates a newInputStreamthat will decompress data using the LZ4 algorithm. -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()longReturns the optional Content Size value set in Frame Descriptor.booleanChecks if the optionnal Content Size is set (FLG.Bits.CONTENT_SIZE is enabled).voidmark(int readlimit) booleanintread()intread(byte[] b, int off, int len) voidreset()longskip(long n) Methods inherited from class java.io.FilterInputStream
readMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
LZ4FrameInputStream
Creates a newInputStreamthat will decompress data using fastest instances ofLZ4SafeDecompressorandXXHash32. This instance will decompress all concatenated frames in their sequential order.- Parameters:
in- the stream to decompress- Throws:
IOException- if an I/O error occurs- See Also:
-
LZ4FrameInputStream
Creates a newInputStreamthat will decompress data using fastest instances ofLZ4SafeDecompressorandXXHash32.- Parameters:
in- the stream to decompressreadSingleFrame- whether read is stopped after the first non-skippable frame- Throws:
IOException- if an I/O error occurs- See Also:
-
LZ4FrameInputStream
public LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum) throws IOException Creates a newInputStreamthat will decompress data using the LZ4 algorithm. This instance will decompress all concatenated frames in their sequential order.- Parameters:
in- the stream to decompressdecompressor- the decompressor to usechecksum- the hash function to use- Throws:
IOException- if an I/O error occurs- See Also:
-
LZ4FrameInputStream
public LZ4FrameInputStream(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum, boolean readSingleFrame) throws IOException Creates a newInputStreamthat will decompress data using the LZ4 algorithm.- Parameters:
in- the stream to decompressdecompressor- the decompressor to usechecksum- the hash function to usereadSingleFrame- whether read is stopped after the first non-skippable frame- Throws:
IOException- if an I/O error occurs
-
-
Method Details
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
available
- Overrides:
availablein classFilterInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classFilterInputStream
-
reset
- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classFilterInputStream
-
getExpectedContentSize
Returns the optional Content Size value set in Frame Descriptor. If the Content Size is not set (FLG.Bits.CONTENT_SIZE not enabled) in compressed stream, -1L is returned. A call to this method is valid only when this instance is supposed to read only one frame (readSingleFrame == true).- Returns:
- the expected content size, or -1L if no expected content size is set in the frame.
- Throws:
IOException- On input stream read exception- See Also:
-
isExpectedContentSizeDefined
Checks if the optionnal Content Size is set (FLG.Bits.CONTENT_SIZE is enabled).- Returns:
- true if this instance is supposed to read only one frame and if the optional content size is set in the frame.
- Throws:
IOException- On input stream read exception
-