Documentation of 'net.jpountz.lz4.LZ4Factory' Java class
LZ4Factory
net.jpountz.lz4

Class LZ4Factory



  • public final class LZ4Factory
    extends java.lang.Object
    Entry point for the LZ4 API.

    This class has 3 instances

    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.

    • Method Detail

      • nativeInstance

        public static LZ4Factory nativeInstance()
        Return a 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:

        1. Upon loading this instance, files will be written to the temporary directory of the system. Although these files are supposed to be deleted when the JVM exits, they might remain on systems that don't support removal of files being used such as Windows.
        2. The instance can only be loaded once per JVM. This can be a problem if your application uses multiple class loaders (such as most servlet containers): this instance will only be available to the children of the class loader which has loaded it. As a consequence, it is advised to either not use this instance in webapps or to put this library in the lib directory of your servlet container so that it is loaded by the system class loader.
      • safeInstance

        public static LZ4Factory safeInstance()
        Return a LZ4Factory instance that returns compressors and decompressors that are written with Java's official API.
      • unsafeInstance

        public static LZ4Factory unsafeInstance()
        Return a LZ4Factory instance that returns compressors and decompressors that may use Unsafe to speed up compression and decompression.
      • fastestJavaInstance

        public static LZ4Factory fastestJavaInstance()
        Return the fastest available 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.
      • highCompressor

        public LZ4Compressor highCompressor(int compressionLevel)
        Return a 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:

        1. It should be in range [1, 17]
        2. A compression level higher than 17 would be treated as 17.
        3. A compression level lower than 1 would be treated as 9.

      • main

        public static void main(java.lang.String[] args)
        Prints the fastest instance.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.