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 newInputStream
that will decompress data using fastest instances ofLZ4SafeDecompressor
andXXHash32
.LZ4FrameInputStream
(InputStream in, boolean readSingleFrame) Creates a newInputStream
that will decompress data using fastest instances ofLZ4SafeDecompressor
andXXHash32
.LZ4FrameInputStream
(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum) Creates a newInputStream
that will decompress data using the LZ4 algorithm.LZ4FrameInputStream
(InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum, boolean readSingleFrame) Creates a newInputStream
that will decompress data using the LZ4 algorithm. -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
long
Returns the optional Content Size value set in Frame Descriptor.boolean
Checks if the optionnal Content Size is set (FLG.Bits.CONTENT_SIZE is enabled).void
mark
(int readlimit) boolean
int
read()
int
read
(byte[] b, int off, int len) void
reset()
long
skip
(long n) Methods inherited from class java.io.FilterInputStream
read
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
LZ4FrameInputStream
Creates a newInputStream
that will decompress data using fastest instances ofLZ4SafeDecompressor
andXXHash32
. 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 newInputStream
that will decompress data using fastest instances ofLZ4SafeDecompressor
andXXHash32
.- 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 newInputStream
that 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 newInputStream
that 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:
read
in classFilterInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classFilterInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classFilterInputStream
-
reset
- Overrides:
reset
in classFilterInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in 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
-