Package net.jpountz.lz4
Class LZ4FrameInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- net.jpountz.lz4.LZ4FrameInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class LZ4FrameInputStream extends java.io.FilterInputStreamImplementation 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:
- LZ4 Framing Format Spec 1.5.1
-
-
Constructor Summary
Constructors Constructor Description LZ4FrameInputStream(java.io.InputStream in)Creates a newInputStreamthat will decompress data using fastest instances ofLZ4SafeDecompressorandXXHash32.LZ4FrameInputStream(java.io.InputStream in, boolean readSingleFrame)Creates a newInputStreamthat will decompress data using fastest instances ofLZ4SafeDecompressorandXXHash32.LZ4FrameInputStream(java.io.InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum)Creates a newInputStreamthat will decompress data using the LZ4 algorithm.LZ4FrameInputStream(java.io.InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum, boolean readSingleFrame)Creates a newInputStreamthat will decompress data using the LZ4 algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()longgetExpectedContentSize()Returns the optional Content Size value set in Frame Descriptor.booleanisExpectedContentSizeDefined()Checks if the optionnal Content Size is set (FLG.Bits.CONTENT_SIZE is enabled).voidmark(int readlimit)booleanmarkSupported()intread()intread(byte[] b, int off, int len)voidreset()longskip(long n)
-
-
-
Constructor Detail
-
LZ4FrameInputStream
public LZ4FrameInputStream(java.io.InputStream in) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an I/O error occurs- See Also:
LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32),LZ4Factory.fastestInstance(),XXHashFactory.fastestInstance()
-
LZ4FrameInputStream
public LZ4FrameInputStream(java.io.InputStream in, boolean readSingleFrame) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an I/O error occurs- See Also:
LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32),LZ4Factory.fastestInstance(),XXHashFactory.fastestInstance()
-
LZ4FrameInputStream
public LZ4FrameInputStream(java.io.InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an I/O error occurs- See Also:
LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32, boolean)
-
LZ4FrameInputStream
public LZ4FrameInputStream(java.io.InputStream in, LZ4SafeDecompressor decompressor, XXHash32 checksum, boolean readSingleFrame) throws java.io.IOExceptionCreates 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:
java.io.IOException- if an I/O error occurs
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.FilterInputStream- 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.FilterInputStream- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classjava.io.FilterInputStream
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.FilterInputStream
-
getExpectedContentSize
public long getExpectedContentSize() throws java.io.IOExceptionReturns 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:
java.io.IOException- On input stream read exception- See Also:
LZ4FrameInputStream(InputStream, LZ4SafeDecompressor, XXHash32, boolean)
-
isExpectedContentSizeDefined
public boolean isExpectedContentSizeDefined() throws java.io.IOExceptionChecks 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:
java.io.IOException- On input stream read exception
-
-