public LZ4Transcoder() { super(); lz4Factory = LZ4Factory.fastestJavaInstance(); }
public LZ4Transcoder(int max) { super(max); lz4Factory = LZ4Factory.fastestJavaInstance(); }
/** Prints the fastest instance. */ public static void main(String[] args) { System.out.println("Fastest instance is " + fastestInstance()); System.out.println("Fastest Java instance is " + fastestJavaInstance()); }
/** Prints the fastest instance. */ public static void main(String[] args) { System.out.println("Fastest instance is " + fastestInstance()); System.out.println("Fastest Java instance is " + fastestJavaInstance()); }
/** * Return the fastest available {@link LZ4Factory} instance. If the class * loader is the system class loader and if the * {@link #nativeInstance() native instance} loads successfully, then the * {@link #nativeInstance() native instance} is returned, otherwise the * {@link #fastestJavaInstance() fastest Java instance} is returned. * <p> * Please read {@link #nativeInstance() javadocs of nativeInstance()} before * using this method. */ public static LZ4Factory fastestInstance() { if (Native.isLoaded() || Native.class.getClassLoader() == ClassLoader.getSystemClassLoader()) { try { return nativeInstance(); } catch (Throwable t) { return fastestJavaInstance(); } } else { return fastestJavaInstance(); } }
/** * Return the fastest available {@link LZ4Factory} instance. If the class * loader is the system class loader and if the * {@link #nativeInstance() native instance} loads successfully, then the * {@link #nativeInstance() native instance} is returned, otherwise the * {@link #fastestJavaInstance() fastest Java instance} is returned. * <p> * Please read {@link #nativeInstance() javadocs of nativeInstance()} before * using this method. */ public static LZ4Factory fastestInstance() { if (Native.isLoaded() || Native.class.getClassLoader() == ClassLoader.getSystemClassLoader()) { try { return nativeInstance(); } catch (Throwable t) { return fastestJavaInstance(); } } else { return fastestJavaInstance(); } }
public LZ4CompressionImplementation() { LZ4Factory instance; boolean nativeInstance; if (Native.isLoaded() || Native.class.getClassLoader() == ClassLoader.getSystemClassLoader()) { try { instance = LZ4Factory.nativeInstance(); nativeInstance = true; } catch (Throwable t) { instance = LZ4Factory.fastestJavaInstance(); nativeInstance = false; } } else { instance = LZ4Factory.fastestJavaInstance(); nativeInstance = false; } if (!nativeInstance) { System.err.println("Cannot load native LZ4 implementation, falling back to slower Java implementation."); } this.nativeInstance = nativeInstance; compressor = instance.fastCompressor(); decompressor = instance.fastDecompressor(); }