当前位置: 首页>>代码示例>>Java>>正文


Java ZlibFactory.setCompressionLevel方法代码示例

本文整理汇总了Java中org.apache.hadoop.io.compress.zlib.ZlibFactory.setCompressionLevel方法的典型用法代码示例。如果您正苦于以下问题:Java ZlibFactory.setCompressionLevel方法的具体用法?Java ZlibFactory.setCompressionLevel怎么用?Java ZlibFactory.setCompressionLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.io.compress.zlib.ZlibFactory的用法示例。


在下文中一共展示了ZlibFactory.setCompressionLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGzipCodecWithParam

import org.apache.hadoop.io.compress.zlib.ZlibFactory; //导入方法依赖的package包/类
@Test
public void testGzipCodecWithParam() throws IOException {
  Configuration conf = new Configuration(this.conf);
  ZlibFactory.setCompressionLevel(conf, CompressionLevel.BEST_COMPRESSION);
  ZlibFactory.setCompressionStrategy(conf, CompressionStrategy.HUFFMAN_ONLY);
  codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.GzipCodec");
  codecTest(conf, seed, count, "org.apache.hadoop.io.compress.GzipCodec");
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:TestCodec.java

示例2: gzipReinitTest

import org.apache.hadoop.io.compress.zlib.ZlibFactory; //导入方法依赖的package包/类
private static void gzipReinitTest(Configuration conf, CompressionCodec codec)
    throws IOException {
  // Add codec to cache
  ZlibFactory.setCompressionLevel(conf, CompressionLevel.BEST_COMPRESSION);
  ZlibFactory.setCompressionStrategy(conf,
      CompressionStrategy.DEFAULT_STRATEGY);
  Compressor c1 = CodecPool.getCompressor(codec);
  CodecPool.returnCompressor(c1);
  // reset compressor's compression level to perform no compression
  ZlibFactory.setCompressionLevel(conf, CompressionLevel.NO_COMPRESSION);
  Compressor c2 = CodecPool.getCompressor(codec, conf);
  // ensure same compressor placed earlier
  assertTrue("Got mismatched ZlibCompressor", c1 == c2);
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  CompressionOutputStream cos = null;
  // write trivially compressable data
  byte[] b = new byte[1 << 15];
  Arrays.fill(b, (byte) 43);
  try {
    cos = codec.createOutputStream(bos, c2);
    cos.write(b);
  } finally {
    if (cos != null) {
      cos.close();
    }
    CodecPool.returnCompressor(c2);
  }
  byte[] outbytes = bos.toByteArray();
  // verify data were not compressed
  assertTrue("Compressed bytes contrary to configuration",
             outbytes.length >= b.length);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:33,代码来源:TestCodec.java

示例3: codecTestWithNOCompression

import org.apache.hadoop.io.compress.zlib.ZlibFactory; //导入方法依赖的package包/类
private static void codecTestWithNOCompression (Configuration conf,
                    String codecClass) throws IOException {
  // Create a compressor with NO_COMPRESSION and make sure that
  // output is not compressed by comparing the size with the
  // original input

  CompressionCodec codec = null;
  ZlibFactory.setCompressionLevel(conf, CompressionLevel.NO_COMPRESSION);
  try {
    codec = (CompressionCodec)
      ReflectionUtils.newInstance(conf.getClassByName(codecClass), conf);
  } catch (ClassNotFoundException cnfe) {
    throw new IOException("Illegal codec!");
  }
  Compressor c = codec.createCompressor();
  // ensure same compressor placed earlier
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  CompressionOutputStream cos = null;
  // write trivially compressable data
  byte[] b = new byte[1 << 15];
  Arrays.fill(b, (byte) 43);
  try {
    cos = codec.createOutputStream(bos, c);
    cos.write(b);
  } finally {
    if (cos != null) {
      cos.close();
    }
  }
  byte[] outbytes = bos.toByteArray();
  // verify data were not compressed
  assertTrue("Compressed bytes contrary to configuration(NO_COMPRESSION)",
             outbytes.length >= b.length);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:35,代码来源:TestCodec.java

示例4: testGzipCompressStreamReuseWithParam

import org.apache.hadoop.io.compress.zlib.ZlibFactory; //导入方法依赖的package包/类
@Test
public void testGzipCompressStreamReuseWithParam() throws IOException {
  Configuration conf = new Configuration(this.conf);
  ZlibFactory
      .setCompressionLevel(conf, CompressionLevel.BEST_COMPRESSION);
  ZlibFactory.setCompressionStrategy(conf,
      CompressionStrategy.HUFFMAN_ONLY);
  resetStateTest(conf, seed, count,
      "org.apache.hadoop.io.compress.GzipCodec");
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:TestCompressionStreamReuse.java

示例5: testGzipCodecWithParam

import org.apache.hadoop.io.compress.zlib.ZlibFactory; //导入方法依赖的package包/类
public void testGzipCodecWithParam() throws IOException {
  Configuration conf = new Configuration(this.conf);
  ZlibFactory.setCompressionLevel(conf, CompressionLevel.BEST_COMPRESSION);
  ZlibFactory.setCompressionStrategy(conf, CompressionStrategy.HUFFMAN_ONLY);
  codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.GzipCodec");
  codecTest(conf, seed, count, "org.apache.hadoop.io.compress.GzipCodec");
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:8,代码来源:TestCodec.java


注:本文中的org.apache.hadoop.io.compress.zlib.ZlibFactory.setCompressionLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。