/** * Return the appropriate implementation of the zlib compressor. * * @param conf configuration * @return the appropriate implementation of the zlib compressor. */ public static Compressor getZlibCompressor(Configuration conf) { return (isNativeZlibLoaded(conf)) ? new ZlibCompressor(conf) : new BuiltInZlibDeflater(ZlibFactory.getCompressionLevel(conf).compressionLevel()); }
/** * reinit the compressor with the given configuration. It will reset the * compressor's compression level and compression strategy. Different from * <tt>ZlibCompressor</tt>, <tt>BuiltInZlibDeflater</tt> only support three * kind of compression strategy: FILTERED, HUFFMAN_ONLY and DEFAULT_STRATEGY. * It will use DEFAULT_STRATEGY as default if the configured compression * strategy is not supported. */ @Override public void reinit(Configuration conf) { reset(); if (conf == null) { return; } setLevel(ZlibFactory.getCompressionLevel(conf).compressionLevel()); final ZlibCompressor.CompressionStrategy strategy = ZlibFactory.getCompressionStrategy(conf); try { setStrategy(strategy.compressionStrategy()); } catch (IllegalArgumentException ill) { LOG.warn(strategy + " not supported by BuiltInZlibDeflater."); setStrategy(DEFAULT_STRATEGY); } if(LOG.isDebugEnabled()) { LOG.debug("Reinit compressor with new compression configuration"); } } }
/** * reinit the compressor with the given configuration. It will reset the * compressor's compression level and compression strategy. Different from * <tt>ZlibCompressor</tt>, <tt>BuiltInZlibDeflater</tt> only support three * kind of compression strategy: FILTERED, HUFFMAN_ONLY and DEFAULT_STRATEGY. * It will use DEFAULT_STRATEGY as default if the configured compression * strategy is not supported. */ @Override public void reinit(Configuration conf) { reset(); if (conf == null) { return; } setLevel(ZlibFactory.getCompressionLevel(conf).compressionLevel()); final ZlibCompressor.CompressionStrategy strategy = ZlibFactory.getCompressionStrategy(conf); try { setStrategy(strategy.compressionStrategy()); } catch (IllegalArgumentException ill) { LOG.warn(strategy + " not supported by BuiltInZlibDeflater."); setStrategy(DEFAULT_STRATEGY); } if(LOG.isDebugEnabled()) { LOG.debug("Reinit compressor with new compression configuration"); } } }
/** * Return the appropriate implementation of the zlib compressor. * * @param conf configuration * @return the appropriate implementation of the zlib compressor. */ public static Compressor getZlibCompressor(Configuration conf) { return (isNativeZlibLoaded(conf)) ? new ZlibCompressor() : new BuiltInZlibDeflater(); }
/** * reinit the compressor with the given configuration. It will reset the * compressor's compression level and compression strategy. Different from * <tt>ZlibCompressor</tt>, <tt>BuiltInZlibDeflater</tt> only support three * kind of compression strategy: FILTERED, HUFFMAN_ONLY and DEFAULT_STRATEGY. * It will use DEFAULT_STRATEGY as default if the configured compression * strategy is not supported. */ @Override public void reinit(Configuration conf) { reset(); if (conf == null) { return; } setLevel(ZlibFactory.getCompressionLevel(conf).compressionLevel()); final ZlibCompressor.CompressionStrategy strategy = ZlibFactory.getCompressionStrategy(conf); try { setStrategy(strategy.compressionStrategy()); } catch (IllegalArgumentException ill) { LOG.warn(strategy + " not supported by BuiltInZlibDeflater."); setStrategy(DEFAULT_STRATEGY); } if(LOG.isDebugEnabled()) { LOG.debug("Reinit compressor with new compression configuration"); } } }
/** * Return the appropriate implementation of the zlib compressor. * * @param conf configuration * @return the appropriate implementation of the zlib compressor. */ public static Compressor getZlibCompressor(Configuration conf) { return (isNativeZlibLoaded(conf)) ? new ZlibCompressor() : new BuiltInZlibDeflater(); }
/** * reinit the compressor with the given configuration. It will reset the * compressor's compression level and compression strategy. Different from * <tt>ZlibCompressor</tt>, <tt>BuiltInZlibDeflater</tt> only support three * kind of compression strategy: FILTERED, HUFFMAN_ONLY and DEFAULT_STRATEGY. * It will use DEFAULT_STRATEGY as default if the configured compression * strategy is not supported. */ @Override public void reinit(Configuration conf) { reset(); if (conf == null) { return; } setLevel(ZlibFactory.getCompressionLevel(conf).compressionLevel()); final ZlibCompressor.CompressionStrategy strategy = ZlibFactory.getCompressionStrategy(conf); try { setStrategy(strategy.compressionStrategy()); } catch (IllegalArgumentException ill) { LOG.warn(strategy + " not supported by BuiltInZlibDeflater."); setStrategy(DEFAULT_STRATEGY); } if(LOG.isDebugEnabled()) { LOG.debug("Reinit compressor with new compression configuration"); } } }
/** * Return the appropriate implementation of the zlib compressor. * * @param conf configuration * @return the appropriate implementation of the zlib compressor. */ public static Compressor getZlibCompressor(Configuration conf) { return (isNativeZlibLoaded(conf)) ? new ZlibCompressor(conf) : new BuiltInZlibDeflater(ZlibFactory.getCompressionLevel(conf).compressionLevel()); }
/** * reinit the compressor with the given configuration. It will reset the * compressor's compression level and compression strategy. Different from * <tt>ZlibCompressor</tt>, <tt>BuiltInZlibDeflater</tt> only support three * kind of compression strategy: FILTERED, HUFFMAN_ONLY and DEFAULT_STRATEGY. * It will use DEFAULT_STRATEGY as default if the configured compression * strategy is not supported. */ @Override public void reinit(Configuration conf) { reset(); if (conf == null) { return; } setLevel(ZlibFactory.getCompressionLevel(conf).compressionLevel()); final ZlibCompressor.CompressionStrategy strategy = ZlibFactory.getCompressionStrategy(conf); try { setStrategy(strategy.compressionStrategy()); } catch (IllegalArgumentException ill) { LOG.warn(strategy + " not supported by BuiltInZlibDeflater."); setStrategy(DEFAULT_STRATEGY); } if(LOG.isDebugEnabled()) { LOG.debug("Reinit compressor with new compression configuration"); } } }
/** * Return the appropriate implementation of the zlib compressor. * * @param conf configuration * @return the appropriate implementation of the zlib compressor. */ public static Compressor getZlibCompressor(Configuration conf) { return (isNativeZlibLoaded(conf)) ? new ZlibCompressor(conf) : new BuiltInZlibDeflater(ZlibFactory.getCompressionLevel(conf).compressionLevel()); }
/** * Return the appropriate implementation of the zlib compressor. * * @param conf configuration * @return the appropriate implementation of the zlib compressor. */ public static Compressor getZlibCompressor(Configuration conf) { return (isNativeZlibLoaded(conf)) ? new ZlibCompressor(conf) : new BuiltInZlibDeflater(ZlibFactory.getCompressionLevel(conf).compressionLevel()); }
/** * Return the appropriate implementation of the zlib compressor. * * @param conf configuration * @return the appropriate implementation of the zlib compressor. */ public static Compressor getZlibCompressor(Configuration conf) { return (isNativeZlibLoaded(conf)) ? new ZlibCompressor(conf) : new BuiltInZlibDeflater(ZlibFactory.getCompressionLevel(conf).compressionLevel()); }
@Test public void testCompressorDecompressor() { // no more for this data int SIZE = 44 * 1024; byte[] rawData = generate(SIZE); try { CompressDecompressTester.of(rawData) .withCompressDecompressPair(new SnappyCompressor(), new SnappyDecompressor()) .withCompressDecompressPair(new Lz4Compressor(), new Lz4Decompressor()) .withCompressDecompressPair(new BuiltInZlibDeflater(), new BuiltInZlibInflater()) .withTestCases(ImmutableSet.of(CompressionTestStrategy.COMPRESS_DECOMPRESS_SINGLE_BLOCK, CompressionTestStrategy.COMPRESS_DECOMPRESS_BLOCK, CompressionTestStrategy.COMPRESS_DECOMPRESS_ERRORS, CompressionTestStrategy.COMPRESS_DECOMPRESS_WITH_EMPTY_STREAM)) .test(); } catch (Exception ex) { fail("testCompressorDecompressor error !!!" + ex); } }
@Test public void testCompressorDecompressor() { // no more for this data int SIZE = 44 * 1024; byte[] rawData = generate(SIZE); try { CompressDecompressTester.of(rawData) .withCompressDecompressPair(new SnappyCompressor(), new SnappyDecompressor()) .withCompressDecompressPair(new Lz4Compressor(), new Lz4Decompressor()) .withCompressDecompressPair(new BuiltInZlibDeflater(), new BuiltInZlibInflater()) .withTestCases(ImmutableSet.of(CompressionTestStrategy.COMPRESS_DECOMPRESS_SINGLE_BLOCK, CompressionTestStrategy.COMPRESS_DECOMPRESS_BLOCK, CompressionTestStrategy.COMPRESS_DECOMPRESS_ERRORS, CompressionTestStrategy.COMPRESS_DECOMPRESS_WITH_EMPTY_STREAM)) .test(); } catch (Exception ex) { fail("testCompressorDecompressor error !!!" + ex); } }