public final class LZ4Factory
extends java.lang.Object
This class has 3 instances
native
instance which is a JNI binding to
the original LZ4 C implementation.
safe Java
instance which is a pure Java port
of the original C library,unsafe Java
instance which is a Java port
using the unofficial Unsafe
API.
Only the safe instance
is guaranteed to work on your
JVM, as a consequence it is advised to use the fastestInstance()
or
fastestJavaInstance()
to pull a LZ4Factory
instance.
All methods from this class are very costly, so you should get an instance
once, and then reuse it whenever possible. This is typically done by storing
a LZ4Factory
instance in a static field.
Modifier and Type | Method and Description |
---|---|
LZ4Decompressor |
decompressor()
Deprecated.
|
LZ4Compressor |
fastCompressor()
Returns a blazing fast
LZ4Compressor . |
LZ4FastDecompressor |
fastDecompressor()
Returns a
LZ4FastDecompressor instance. |
static LZ4Factory |
fastestInstance()
Returns the fastest available
LZ4Factory instance. |
static LZ4Factory |
fastestJavaInstance()
Returns the fastest available
LZ4Factory instance which does not
rely on JNI bindings. |
LZ4Compressor |
highCompressor()
Returns a
LZ4Compressor which requires more memory than
fastCompressor() and is slower but compresses more efficiently. |
LZ4Compressor |
highCompressor(int compressionLevel)
Returns a
LZ4Compressor which requires more memory than
fastCompressor() and is slower but compresses more efficiently. |
static void |
main(java.lang.String[] args)
Prints the fastest instance.
|
static LZ4Factory |
nativeInstance()
Returns a
LZ4Factory instance that returns compressors and
decompressors that are native bindings to the original C library. |
LZ4SafeDecompressor |
safeDecompressor()
Returns a
LZ4SafeDecompressor instance. |
static LZ4Factory |
safeInstance()
Returns a
LZ4Factory instance that returns compressors and
decompressors that are written with Java's official API. |
java.lang.String |
toString() |
LZ4UnknownSizeDecompressor |
unknownSizeDecompressor()
Deprecated.
|
static LZ4Factory |
unsafeInstance()
Returns a
LZ4Factory instance that returns compressors and
decompressors that may use Unsafe to speed up compression
and decompression. |
public static LZ4Factory nativeInstance()
LZ4Factory
instance that returns compressors and
decompressors that are native bindings to the original C library.
Please note that this instance has some traps you should be aware of:
LZ4FastDecompressor
instance
returned by fastDecompressor()
of this instance is SLOWER
than a LZ4SafeDecompressor
instance returned by
safeDecompressor()
, due to a change in the original LZ4
C implementation. The corresponding C API function is deprecated.
Hence use of fastDecompressor()
is deprecated
for this instance.
LZ4Factory
instance that returns compressors and
decompressors that are native bindings to the original C librarypublic static LZ4Factory safeInstance()
LZ4Factory
instance that returns compressors and
decompressors that are written with Java's official API.LZ4Factory
instance that returns compressors and
decompressors that are written with Java's official API.public static LZ4Factory unsafeInstance()
LZ4Factory
instance that returns compressors and
decompressors that may use Unsafe
to speed up compression
and decompression.LZ4Factory
instance that returns compressors and
decompressors that may use Unsafe
to speed up compression
and decompression.public static LZ4Factory fastestJavaInstance()
LZ4Factory
instance which does not
rely on JNI bindings. It first tries to load the
unsafe instance
, and then the
safe Java instance
if the JVM doesn't have a
working Unsafe
.LZ4Factory
instance which does not
rely on JNI bindings.public static LZ4Factory fastestInstance()
LZ4Factory
instance. If the class
loader is the system class loader and if the
native instance
loads successfully, then the
native instance
is returned, otherwise the
fastest Java instance
is returned.
Please read javadocs of nativeInstance()
before
using this method.
LZ4Factory
instancepublic LZ4Compressor fastCompressor()
LZ4Compressor
.LZ4Compressor
public LZ4Compressor highCompressor()
LZ4Compressor
which requires more memory than
fastCompressor()
and is slower but compresses more efficiently.LZ4Compressor
which requires more memory than
fastCompressor()
and is slower but compresses more efficiently.public LZ4Compressor highCompressor(int compressionLevel)
LZ4Compressor
which requires more memory than
fastCompressor()
and is slower but compresses more efficiently.
The compression level can be customized.
For current implementations, the following is true about compression level:
compressionLevel
- the compression level between [1, 17]; the higher the level, the higher the compression ratioLZ4Compressor
which requires more memory than
fastCompressor()
and is slower but compresses more efficiently.public LZ4FastDecompressor fastDecompressor()
LZ4FastDecompressor
instance.
Use of this method is deprecated for the native instance
.LZ4FastDecompressor
instancenativeInstance()
public LZ4SafeDecompressor safeDecompressor()
LZ4SafeDecompressor
instance.LZ4SafeDecompressor
instancepublic LZ4UnknownSizeDecompressor unknownSizeDecompressor()
safeDecompressor()
LZ4UnknownSizeDecompressor
instance.LZ4UnknownSizeDecompressor
instancepublic LZ4Decompressor decompressor()
fastDecompressor()
LZ4Decompressor
instance.LZ4Decompressor
instancepublic static void main(java.lang.String[] args)
args
- no argument requiredpublic java.lang.String toString()
toString
in class java.lang.Object