public Deflater makeDeflater(final int compressionLevel, final boolean nowrap) { boolean intelDeflaterSupported = new IntelDeflater().load(tmpDir); if (intelDeflaterSupported) { if ((compressionLevel == 1 && nowrap) || compressionLevel != 1) { usingIntelDeflater = true; return new IntelDeflater(compressionLevel, nowrap); } } logger.warn("IntelDeflater is not supported, using Java.util.zip.Deflater"); usingIntelDeflater = false; return new Deflater(compressionLevel, nowrap); }
/** * Returns an IntelDeflater if supported on the platform, otherwise returns a Java Deflater * * @param compressionLevel the compression level (0-9) * @param gzipCompatible if true the use GZIP compatible compression * @return a Deflater object */ public Deflater makeDeflater(final int compressionLevel, final boolean gzipCompatible) { if (intelDeflaterSupported) { if ((compressionLevel == 1 && gzipCompatible) || compressionLevel != 1) { return new IntelDeflater(compressionLevel, gzipCompatible); } } logger.warn("IntelDeflater is not supported, using Java.util.zip.Deflater"); return new Deflater(compressionLevel, gzipCompatible); }
public IntelDeflaterFactory(File tmpDir) { intelDeflaterSupported = new IntelDeflater().load(tmpDir); }
@Test public void testIntelDeflaterIsAvailable() { checkIntelSupported("IntelDeflater"); Assert.assertTrue(new IntelDeflater().load(null), "Intel shared library was not loaded. This could be due to a configuration error, or your system might not support it."); }