net.jpountz.lz4
Class LZ4Compressor
- java.lang.Object
-
- net.jpountz.lz4.LZ4Compressor
-
public abstract class LZ4Compressor extends java.lang.ObjectLZ4 compressor.Instances of this class are thread-safe.
-
-
Constructor Summary
Constructors Constructor and Description LZ4Compressor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description byte[]compress(byte[] src)Convenience method, equivalent to callingcompress(src, 0, src.length).intcompress(byte[] src, byte[] dest)Convenience method, equivalent to callingcompress(src, 0, src.length, dest, 0).byte[]compress(byte[] src, int srcOff, int srcLen)Convenience method which returnssrc[srcOff:srcOff+srcLen]compressed.intcompress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff)Convenience method, equivalent to callingcompress(src, srcOff, srcLen, dest, destOff, dest.length - destOff).abstract intcompress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff, int maxDestLen)Compresssrc[srcOff:srcOff+srcLen]intodest[destOff:destOff+destLen]and return the compressed length.voidcompress(java.nio.ByteBuffer src, java.nio.ByteBuffer dest)Compresssrcintodest.abstract intcompress(java.nio.ByteBuffer src, int srcOff, int srcLen, java.nio.ByteBuffer dest, int destOff, int maxDestLen)Compresssrc[srcOff:srcOff+srcLen]intodest[destOff:destOff+destLen]and return the compressed length.intmaxCompressedLength(int length)Return the maximum compressed length for an input of sizelength.java.lang.StringtoString()
-
-
-
Method Detail
-
maxCompressedLength
public final int maxCompressedLength(int length)
Return the maximum compressed length for an input of sizelength.
-
compress
public abstract int compress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff, int maxDestLen)Compresssrc[srcOff:srcOff+srcLen]intodest[destOff:destOff+destLen]and return the compressed length. This method will throw aLZ4Exceptionif this compressor is unable to compress the input into less thanmaxDestLenbytes. To prevent this exception to be thrown, you should make sure thatmaxDestLen >= maxCompressedLength(srcLen).- Returns:
- the compressed size
- Throws:
LZ4Exception- if maxDestLen is too small
-
compress
public abstract int compress(java.nio.ByteBuffer src, int srcOff, int srcLen, java.nio.ByteBuffer dest, int destOff, int maxDestLen)Compresssrc[srcOff:srcOff+srcLen]intodest[destOff:destOff+destLen]and return the compressed length. This method will throw aLZ4Exceptionif this compressor is unable to compress the input into less thanmaxDestLenbytes. To prevent this exception to be thrown, you should make sure thatmaxDestLen >= maxCompressedLength(srcLen).ByteBufferpositions remain unchanged.- Returns:
- the compressed size
- Throws:
LZ4Exception- if maxDestLen is too small
-
compress
public final int compress(byte[] src, int srcOff, int srcLen, byte[] dest, int destOff)Convenience method, equivalent to callingcompress(src, srcOff, srcLen, dest, destOff, dest.length - destOff).
-
compress
public final int compress(byte[] src, byte[] dest)Convenience method, equivalent to callingcompress(src, 0, src.length, dest, 0).
-
compress
public final byte[] compress(byte[] src, int srcOff, int srcLen)Convenience method which returnssrc[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);
-
compress
public final byte[] compress(byte[] src)
Convenience method, equivalent to callingcompress(src, 0, src.length).
-
compress
public final void compress(java.nio.ByteBuffer src, java.nio.ByteBuffer dest)Compresssrcintodest. Calling this method will update the positions of bothByteBuffers.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG