Top Description Constructors Methods
net.jpountz.lz4

public abstract Class LZ4Compressor

extends Object
Class Inheritance
Known Direct Subclasses
net.jpountz.lz4.LZ4HCJNICompressor, net.jpountz.lz4.LZ4JNICompressor
Imports
java.nio.ByteBuffer, java.util.Arrays

LZ4 compressor.

Instances of this class are thread-safe.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract int

Returns:

the compressed size
compress
(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff, int maxDestLen)

Compress src[srcOff:srcOff+srcLen] into dest[destOff:destOff+destLen] and return the compressed length.

public abstract int

Returns:

the compressed size
compress
(ByteBuffer src, int srcOff, int srcLen, ByteBuffer dest, int destOff, int maxDestLen)

Compress src[srcOff:srcOff+srcLen] into dest[destOff:destOff+destLen] and return the compressed length.

public final int
compress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff)

Convenience method, equivalent to calling compress(src, srcOff, srcLen, dest, destOff, dest.length - destOff).

public final int
compress(byte[] src, byte[] dest)

Convenience method, equivalent to calling compress(src, 0, src.length, dest, 0).

public final byte[]
compress(byte[] src, int srcOff, int srcLen)

Convenience method which returns src[srcOff:srcOff+srcLen] compressed.

public final byte[]
compress(byte[] src)

Convenience method, equivalent to calling compress(src, 0, src.length).

public final void
compress(ByteBuffer src, ByteBuffer dest)

Compress src into dest.

public final int
maxCompressedLength(int length)

Return the maximum compressed length for an input of size length.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Constructor Detail

LZ4Compressorback to summary
public LZ4Compressor()

Method Detail

compressback to summary
public abstract int compress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff, int maxDestLen)

Compress src[srcOff:srcOff+srcLen] into dest[destOff:destOff+destLen] and return the compressed length. This method will throw a LZ4Exception if this compressor is unable to compress the input into less than maxDestLen bytes. To prevent this exception to be thrown, you should make sure that maxDestLen >= maxCompressedLength(srcLen).

Returns:int

the compressed size

Exceptions
LZ4Exception:
if maxDestLen is too small
compressback to summary
public abstract int compress(ByteBuffer src, int srcOff, int srcLen, ByteBuffer dest, int destOff, int maxDestLen)

Compress src[srcOff:srcOff+srcLen] into dest[destOff:destOff+destLen] and return the compressed length. This method will throw a LZ4Exception if this compressor is unable to compress the input into less than maxDestLen bytes. To prevent this exception to be thrown, you should make sure that maxDestLen >= maxCompressedLength(srcLen). ByteBuffer positions remain unchanged.

Returns:int

the compressed size

Exceptions
LZ4Exception:
if maxDestLen is too small
compressback to summary
public final int compress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff)

Convenience method, equivalent to calling compress(src, srcOff, srcLen, dest, destOff, dest.length - destOff).

compressback to summary
public final int compress(byte[] src, byte[] dest)

Convenience method, equivalent to calling compress(src, 0, src.length, dest, 0).

compressback to summary
public final byte[] compress(byte[] src, int srcOff, int srcLen)

Convenience method which returns src[srcOff:srcOff+srcLen] compressed.

Warning: this method has an important overhead due to the fact that it needs to allocate a buffer to compress into, and then needs to resize this buffer to the actual compressed length.

Here is how this method is implemented:

final int maxCompressedLength = maxCompressedLength(srcLen);
final byte[] compressed = new byte[maxCompressedLength];
final int compressedLength = compress(src, srcOff, srcLen, compressed, 0);
return Arrays.copyOf(compressed, compressedLength);
compressback to summary
public final byte[] compress(byte[] src)

Convenience method, equivalent to calling compress(src, 0, src.length).

compressback to summary
public final void compress(ByteBuffer src, ByteBuffer dest)

Compress src into dest. Calling this method will update the positions of both ByteBuffers.

maxCompressedLengthback to summary
public final int maxCompressedLength(int length)

Return the maximum compressed length for an input of size length.

Annotations
@SuppressWarnings:static-method
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override