Package net.jpountz.lz4
Class LZ4DecompressorWithLength
java.lang.Object
net.jpountz.lz4.LZ4DecompressorWithLength
Convenience class to decompress data compressed by
LZ4CompressorWithLength
.
This decompressor is NOT compatible with any other compressors in lz4-java
or any other lz4 tools.
The user does not need to specify the length of the compressed data or
original data because the length of the original decompressed data is
included in the compressed data.-
Constructor Summary
ConstructorsConstructorDescriptionLZ4DecompressorWithLength
(LZ4FastDecompressor fastDecompressor) Creates a new decompressor to decompress data compressed byLZ4CompressorWithLength
.LZ4DecompressorWithLength
(LZ4SafeDecompressor safeDecompressor) Creates a new decompressor to decompress data compressed byLZ4CompressorWithLength
. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
decompress
(byte[] src) Convenience method, equivalent to callingdecompress(src, 0)
.int
decompress
(byte[] src, byte[] dest) Convenience method, equivalent to callingdecompress(src, 0, dest, 0)
.byte[]
decompress
(byte[] src, int srcOff) Convenience method which returnssrc[srcOff:]
decompressed whenLZ4FastDecompressor
was specified to the constructor, orsrc[srcOff:src.length]
decompressed whenLZ4SafeDecompressor
was specified to the constructor.int
decompress
(byte[] src, int srcOff, byte[] dest, int destOff) WhenLZ4FastDecompressor
was specified to the constructor, decompressessrc[srcOff:]
intodest[destOff:]
and returns the number of bytes read fromsrc
, and whenLZ4SafeDecompressor
was specified to the constructor, decompressessrc[srcOff:src.length]
intodest[destOff:]
and returns the number of decompressed bytes written intodest
.byte[]
decompress
(byte[] src, int srcOff, int srcLen) Convenience method which returnssrc[srcOff:]
decompressed whenLZ4FastDecompressor
was specified to the constructor, orsrc[srcOff:srcOff+srcLen]
decompressed whenLZ4SafeDecompressor
was specified to the constructor.int
decompress
(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff) WhenLZ4FastDecompressor
was specified to the constructor, decompressessrc[srcOff:]
intodest[destOff:]
and returns the number of bytes read fromsrc
, and whenLZ4SafeDecompressor
was specified to the constructor, decompressessrc[srcOff:srcOff+srcLen]
intodest[destOff:]
and returns the number of decompressed bytes written intodest
.int
decompress
(ByteBuffer src, int srcOff, int srcLen, ByteBuffer dest, int destOff) WhenLZ4FastDecompressor
was specified to the constructor, decompressessrc[srcOff:]
intodest[destOff:]
and returns the number of bytes read fromsrc
, and whenLZ4SafeDecompressor
was specified to the constructor, decompressessrc[srcOff:srcOff+srcLen]
intodest[destOff:]
and returns the number of decompressed bytes written intodest
.int
decompress
(ByteBuffer src, int srcOff, ByteBuffer dest, int destOff) WhenLZ4FastDecompressor
was specified to the constructor, decompressessrc[srcOff:]
intodest[destOff:]
and returns the number of bytes read fromsrc
, and whenLZ4SafeDecompressor
was specified to the constructor, decompressessrc[srcOff:src.remaining()]
intodest[destOff:]
and returns the number of decompressed bytes written intodest
.void
decompress
(ByteBuffer src, ByteBuffer dest) Decompressessrc
intodest
.static int
getDecompressedLength
(byte[] src) Returns the decompressed length of compressed data insrc
.static int
getDecompressedLength
(byte[] src, int srcOff) Returns the decompressed length of compressed data insrc[srcOff:]
.static int
Returns the decompressed length of compressed data insrc
.static int
getDecompressedLength
(ByteBuffer src, int srcOff) Returns the decompressed length of compressed data insrc[srcOff:]
.
-
Constructor Details
-
LZ4DecompressorWithLength
Creates a new decompressor to decompress data compressed byLZ4CompressorWithLength
. Note that it is deprecated to use a JNI-binding instance ofLZ4FastDecompressor
. Please seeLZ4Factory.nativeInstance()
for details.- Parameters:
fastDecompressor
- fast decompressor to use
-
LZ4DecompressorWithLength
Creates a new decompressor to decompress data compressed byLZ4CompressorWithLength
.- Parameters:
safeDecompressor
- safe decompressor to use
-
-
Method Details
-
getDecompressedLength
public static int getDecompressedLength(byte[] src) Returns the decompressed length of compressed data insrc
.- Parameters:
src
- the compressed data- Returns:
- the decompressed length
-
getDecompressedLength
public static int getDecompressedLength(byte[] src, int srcOff) Returns the decompressed length of compressed data insrc[srcOff:]
.- Parameters:
src
- the compressed datasrcOff
- the start offset in src- Returns:
- the decompressed length
-
getDecompressedLength
Returns the decompressed length of compressed data insrc
.- Parameters:
src
- the compressed data- Returns:
- the decompressed length
-
getDecompressedLength
Returns the decompressed length of compressed data insrc[srcOff:]
.- Parameters:
src
- the compressed datasrcOff
- the start offset in src- Returns:
- the decompressed length
-
decompress
public int decompress(byte[] src, byte[] dest) Convenience method, equivalent to callingdecompress(src, 0, dest, 0)
.- Parameters:
src
- the compressed datadest
- the destination buffer to store the decompressed data- Returns:
- the number of bytes read to restore the original input
-
decompress
public int decompress(byte[] src, int srcOff, byte[] dest, int destOff) WhenLZ4FastDecompressor
was specified to the constructor, decompressessrc[srcOff:]
intodest[destOff:]
and returns the number of bytes read fromsrc
, and whenLZ4SafeDecompressor
was specified to the constructor, decompressessrc[srcOff:src.length]
intodest[destOff:]
and returns the number of decompressed bytes written intodest
.- Parameters:
src
- the compressed datasrcOff
- the start offset in srcdest
- the destination buffer to store the decompressed datadestOff
- the start offset in dest- Returns:
- the number of bytes read to restore the original input (when
LZ4FastDecompressor
is used), or the number of decompressed bytes (whenLZ4SafeDecompressor
is used)
-
decompress
public int decompress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff) WhenLZ4FastDecompressor
was specified to the constructor, decompressessrc[srcOff:]
intodest[destOff:]
and returns the number of bytes read fromsrc
, and whenLZ4SafeDecompressor
was specified to the constructor, decompressessrc[srcOff:srcOff+srcLen]
intodest[destOff:]
and returns the number of decompressed bytes written intodest
.- Parameters:
src
- the compressed datasrcOff
- the start offset in srcsrcLen
- the exact size of the compressed data (ignored whenLZ4FastDecompressor
is used)dest
- the destination buffer to store the decompressed datadestOff
- the start offset in dest- Returns:
- the number of bytes read to restore the original input (when
LZ4FastDecompressor
is used), or the number of decompressed bytes (whenLZ4SafeDecompressor
is used)
-
decompress
public byte[] decompress(byte[] src) Convenience method, equivalent to callingdecompress(src, 0)
.- Parameters:
src
- the compressed data- Returns:
- the decompressed data
-
decompress
public byte[] decompress(byte[] src, int srcOff) Convenience method which returnssrc[srcOff:]
decompressed whenLZ4FastDecompressor
was specified to the constructor, orsrc[srcOff:src.length]
decompressed whenLZ4SafeDecompressor
was specified to the constructor.Warning: this method has an important overhead due to the fact that it needs to allocate a buffer to decompress into.
- Parameters:
src
- the compressed datasrcOff
- the start offset in src- Returns:
- the decompressed data
-
decompress
public byte[] decompress(byte[] src, int srcOff, int srcLen) Convenience method which returnssrc[srcOff:]
decompressed whenLZ4FastDecompressor
was specified to the constructor, orsrc[srcOff:srcOff+srcLen]
decompressed whenLZ4SafeDecompressor
was specified to the constructor.Warning: this method has an important overhead due to the fact that it needs to allocate a buffer to decompress into.
- Parameters:
src
- the compressed datasrcOff
- the start offset in srcsrcLen
- the exact size of the compressed data (ignored whenLZ4FastDecompressor
is used)- Returns:
- the decompressed data
-
decompress
Decompressessrc
intodest
. WhenLZ4SafeDecompressor
was specified to the constructor,src
'sBuffer.remaining()
must be exactly the size of the compressed data. This method moves the positions of the buffers.- Parameters:
src
- the compressed datadest
- the destination buffer to store the decompressed data
-
decompress
WhenLZ4FastDecompressor
was specified to the constructor, decompressessrc[srcOff:]
intodest[destOff:]
and returns the number of bytes read fromsrc
, and whenLZ4SafeDecompressor
was specified to the constructor, decompressessrc[srcOff:src.remaining()]
intodest[destOff:]
and returns the number of decompressed bytes written intodest
. The positions and limits of theByteBuffer
s remain unchanged.- Parameters:
src
- the compressed datasrcOff
- the start offset in srcdest
- the destination buffer to store the decompressed datadestOff
- the start offset in dest- Returns:
- the number of bytes read to restore the original input (when
LZ4FastDecompressor
is used), or the number of decompressed bytes (whenLZ4SafeDecompressor
is used)
-
decompress
WhenLZ4FastDecompressor
was specified to the constructor, decompressessrc[srcOff:]
intodest[destOff:]
and returns the number of bytes read fromsrc
, and whenLZ4SafeDecompressor
was specified to the constructor, decompressessrc[srcOff:srcOff+srcLen]
intodest[destOff:]
and returns the number of decompressed bytes written intodest
. The positions and limits of theByteBuffer
s remain unchanged.- Parameters:
src
- the compressed datasrcOff
- the start offset in srcsrcLen
- the exact size of the compressed data (ignored whenLZ4FastDecompressor
is used)dest
- the destination buffer to store the decompressed datadestOff
- the start offset in dest- Returns:
- the number of bytes read to restore the original input (when
LZ4FastDecompressor
is used), or the number of decompressed bytes (whenLZ4SafeDecompressor
is used)
-