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


Java BuiltInGzipDecompressor类代码示例

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


BuiltInGzipDecompressor类属于org.apache.hadoop.io.compress.zlib包,在下文中一共展示了BuiltInGzipDecompressor类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGzipCompatibility

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
@Test
public void testGzipCompatibility() throws IOException {
  Random r = new Random();
  long seed = r.nextLong();
  r.setSeed(seed);
  LOG.info("seed: " + seed);

  DataOutputBuffer dflbuf = new DataOutputBuffer();
  GZIPOutputStream gzout = new GZIPOutputStream(dflbuf);
  byte[] b = new byte[r.nextInt(128 * 1024 + 1)];
  r.nextBytes(b);
  gzout.write(b);
  gzout.close();

  DataInputBuffer gzbuf = new DataInputBuffer();
  gzbuf.reset(dflbuf.getData(), dflbuf.getLength());

  Configuration conf = new Configuration();
  // don't use native libs
  ZlibFactory.setNativeZlibLoaded(false);
  CompressionCodec codec = ReflectionUtils.newInstance(GzipCodec.class, conf);
  Decompressor decom = codec.createDecompressor();
  assertNotNull(decom);
  assertEquals(BuiltInGzipDecompressor.class, decom.getClass());
  InputStream gzin = codec.createInputStream(gzbuf, decom);

  dflbuf.reset();
  IOUtils.copyBytes(gzin, dflbuf, 4096);
  final byte[] dflchk = Arrays.copyOf(dflbuf.getData(), dflbuf.getLength());
  assertArrayEquals(b, dflchk);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:32,代码来源:TestCodec.java

示例2: testBuiltInGzipConcat

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
@Test
public void testBuiltInGzipConcat() throws IOException {
  Configuration conf = new Configuration();
  // don't use native libs
  ZlibFactory.setNativeZlibLoaded(false);
  GzipConcatTest(conf, BuiltInGzipDecompressor.class);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:8,代码来源:TestCodec.java

示例3: testGzipCompatibility

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
@Test
public void testGzipCompatibility() throws IOException {
  Random r = new Random();
  long seed = r.nextLong();
  r.setSeed(seed);
  LOG.info("seed: " + seed);

  DataOutputBuffer dflbuf = new DataOutputBuffer();
  GZIPOutputStream gzout = new GZIPOutputStream(dflbuf);
  byte[] b = new byte[r.nextInt(128 * 1024 + 1)];
  r.nextBytes(b);
  gzout.write(b);
  gzout.close();

  DataInputBuffer gzbuf = new DataInputBuffer();
  gzbuf.reset(dflbuf.getData(), dflbuf.getLength());

  Configuration conf = new Configuration();
  conf.setBoolean(CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY, false);
  CompressionCodec codec = ReflectionUtils.newInstance(GzipCodec.class, conf);
  Decompressor decom = codec.createDecompressor();
  assertNotNull(decom);
  assertEquals(BuiltInGzipDecompressor.class, decom.getClass());
  InputStream gzin = codec.createInputStream(gzbuf, decom);

  dflbuf.reset();
  IOUtils.copyBytes(gzin, dflbuf, 4096);
  final byte[] dflchk = Arrays.copyOf(dflbuf.getData(), dflbuf.getLength());
  assertArrayEquals(b, dflchk);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:TestCodec.java

示例4: testGzipCompatibility

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
public void testGzipCompatibility() throws IOException {
  Random r = new Random();
  long seed = r.nextLong();
  r.setSeed(seed);
  LOG.info("seed: " + seed);

  DataOutputBuffer dflbuf = new DataOutputBuffer();
  GZIPOutputStream gzout = new GZIPOutputStream(dflbuf);
  byte[] b = new byte[r.nextInt(128 * 1024 + 1)];
  r.nextBytes(b);
  gzout.write(b);
  gzout.close();

  DataInputBuffer gzbuf = new DataInputBuffer();
  gzbuf.reset(dflbuf.getData(), dflbuf.getLength());

  Configuration conf = new Configuration();
  conf.setBoolean("hadoop.native.lib", false);
  CompressionCodec codec = ReflectionUtils.newInstance(GzipCodec.class, conf);
  Decompressor decom = codec.createDecompressor();
  assertNotNull(decom);
  assertEquals(BuiltInGzipDecompressor.class, decom.getClass());
  InputStream gzin = codec.createInputStream(gzbuf, decom);

  dflbuf.reset();
  IOUtils.copyBytes(gzin, dflbuf, 4096);
  final byte[] dflchk = Arrays.copyOf(dflbuf.getData(), dflbuf.getLength());
  assertTrue(java.util.Arrays.equals(b, dflchk));
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:30,代码来源:TestCodec.java

示例5: testCodecPoolAndGzipDecompressor

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
@Test
public void testCodecPoolAndGzipDecompressor() {
  // BuiltInZlibInflater should not be used as the GzipCodec decompressor.
  // Assert that this is the case.

  // Don't use native libs for this test.
  Configuration conf = new Configuration();
  ZlibFactory.setNativeZlibLoaded(false);
  assertFalse("ZlibFactory is using native libs against request",
              ZlibFactory.isNativeZlibLoaded(conf));

  // This should give us a BuiltInZlibInflater.
  Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);
  assertNotNull("zlibDecompressor is null!", zlibDecompressor);
  assertTrue("ZlibFactory returned unexpected inflator",
      zlibDecompressor instanceof BuiltInZlibInflater);
  // its createOutputStream() just wraps the existing stream in a
  // java.util.zip.GZIPOutputStream.
  CompressionCodecFactory ccf = new CompressionCodecFactory(conf);
  CompressionCodec codec = ccf.getCodec(new Path("foo.gz"));
  assertTrue("Codec for .gz file is not GzipCodec", 
      codec instanceof GzipCodec);

  // make sure we don't get a null decompressor
  Decompressor codecDecompressor = codec.createDecompressor();
  if (null == codecDecompressor) {
    fail("Got null codecDecompressor");
  }

  // Asking the CodecPool for a decompressor for GzipCodec
  // should not return null
  Decompressor poolDecompressor = CodecPool.getDecompressor(codec);
  if (null == poolDecompressor) {
    fail("Got null poolDecompressor");
  }
  // return a couple decompressors
  CodecPool.returnDecompressor(zlibDecompressor);
  CodecPool.returnDecompressor(poolDecompressor);
  Decompressor poolDecompressor2 = CodecPool.getDecompressor(codec);
  if (poolDecompressor.getClass() == BuiltInGzipDecompressor.class) {
    if (poolDecompressor == poolDecompressor2) {
      fail("Reused java gzip decompressor in pool");
    }
  } else {
    if (poolDecompressor != poolDecompressor2) {
      fail("Did not reuse native gzip decompressor in pool");
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:50,代码来源:TestCodec.java

示例6: testBuiltInGzipConcat

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
@Test
public void testBuiltInGzipConcat() throws IOException {
  Configuration conf = new Configuration();
  conf.setBoolean(CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY, false);
  GzipConcatTest(conf, BuiltInGzipDecompressor.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:TestCodec.java

示例7: testCodecPoolAndGzipDecompressor

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
public void testCodecPoolAndGzipDecompressor() {
  // BuiltInZlibInflater should not be used as the GzipCodec decompressor.
  // Assert that this is the case.

  // Don't use native libs for this test.
  Configuration conf = new Configuration();
  conf.setBoolean("hadoop.native.lib", false);
  assertFalse("ZlibFactory is using native libs against request",
              ZlibFactory.isNativeZlibLoaded(conf));

  // This should give us a BuiltInZlibInflater.
  Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);
  assertNotNull("zlibDecompressor is null!", zlibDecompressor);
  assertTrue("ZlibFactory returned unexpected inflator",
      zlibDecompressor instanceof BuiltInZlibInflater);
  // its createOutputStream() just wraps the existing stream in a
  // java.util.zip.GZIPOutputStream.
  CompressionCodecFactory ccf = new CompressionCodecFactory(conf);
  CompressionCodec codec = ccf.getCodec(new Path("foo.gz"));
  assertTrue("Codec for .gz file is not GzipCodec", 
      codec instanceof GzipCodec);

  // make sure we don't get a null decompressor
  Decompressor codecDecompressor = codec.createDecompressor();
  if (null == codecDecompressor) {
    fail("Got null codecDecompressor");
  }

  // Asking the CodecPool for a decompressor for GzipCodec
  // should not return null
  Decompressor poolDecompressor = CodecPool.getDecompressor(codec);
  if (null == poolDecompressor) {
    fail("Got null poolDecompressor");
  }
  // return a couple decompressors
  CodecPool.returnDecompressor(zlibDecompressor);
  CodecPool.returnDecompressor(poolDecompressor);
  Decompressor poolDecompressor2 = CodecPool.getDecompressor(codec);
  if (poolDecompressor.getClass() == BuiltInGzipDecompressor.class) {
    if (poolDecompressor == poolDecompressor2) {
      fail("Reused java gzip decompressor in pool");
    }
  } else {
    if (poolDecompressor != poolDecompressor2) {
      fail("Did not reuse native gzip decompressor in pool");
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:TestCodec.java

示例8: testCodecPoolAndGzipDecompressor

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
@Test
public void testCodecPoolAndGzipDecompressor() {
  // BuiltInZlibInflater should not be used as the GzipCodec decompressor.
  // Assert that this is the case.

  // Don't use native libs for this test.
  Configuration conf = new Configuration();
  conf.setBoolean("hadoop.native.lib", false);
  assertFalse("ZlibFactory is using native libs against request",
              ZlibFactory.isNativeZlibLoaded(conf));

  // This should give us a BuiltInZlibInflater.
  Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);
  assertNotNull("zlibDecompressor is null!", zlibDecompressor);
  assertTrue("ZlibFactory returned unexpected inflator",
      zlibDecompressor instanceof BuiltInZlibInflater);
  // its createOutputStream() just wraps the existing stream in a
  // java.util.zip.GZIPOutputStream.
  CompressionCodecFactory ccf = new CompressionCodecFactory(conf);
  CompressionCodec codec = ccf.getCodec(new Path("foo.gz"));
  assertTrue("Codec for .gz file is not GzipCodec", 
      codec instanceof GzipCodec);

  // make sure we don't get a null decompressor
  Decompressor codecDecompressor = codec.createDecompressor();
  if (null == codecDecompressor) {
    fail("Got null codecDecompressor");
  }

  // Asking the CodecPool for a decompressor for GzipCodec
  // should not return null
  Decompressor poolDecompressor = CodecPool.getDecompressor(codec);
  if (null == poolDecompressor) {
    fail("Got null poolDecompressor");
  }
  // return a couple decompressors
  CodecPool.returnDecompressor(zlibDecompressor);
  CodecPool.returnDecompressor(poolDecompressor);
  Decompressor poolDecompressor2 = CodecPool.getDecompressor(codec);
  if (poolDecompressor.getClass() == BuiltInGzipDecompressor.class) {
    if (poolDecompressor == poolDecompressor2) {
      fail("Reused java gzip decompressor in pool");
    }
  } else {
    if (poolDecompressor != poolDecompressor2) {
      fail("Did not reuse native gzip decompressor in pool");
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:50,代码来源:TestCodec.java

示例9: testBuiltInGzipConcat

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
public void testBuiltInGzipConcat() throws IOException {
  Configuration conf = new Configuration();
  conf.setBoolean("hadoop.native.lib", false);
  GzipConcatTest(conf, BuiltInGzipDecompressor.class);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:6,代码来源:TestCodec.java

示例10: testCodecPoolAndGzipDecompressor

import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor; //导入依赖的package包/类
public void testCodecPoolAndGzipDecompressor() {
  // BuiltInZlibInflater should not be used as the GzipCodec decompressor.
  // Assert that this is the case.

  // Don't use native libs for this test.
  Configuration conf = new Configuration();
  conf.setBoolean("hadoop.native.lib", false);
  assertFalse("ZlibFactory is using native libs against request",
      ZlibFactory.isNativeZlibLoaded(conf));

  // This should give us a BuiltInZlibInflater.
  Decompressor zlibDecompressor = ZlibFactory.getZlibDecompressor(conf);
  assertNotNull("zlibDecompressor is null!", zlibDecompressor);
  assertTrue("ZlibFactory returned unexpected inflator",
      zlibDecompressor instanceof BuiltInZlibInflater);

  // its createOutputStream() just wraps the existing stream in a
  // java.util.zip.GZIPOutputStream.
  CompressionCodecFactory ccf = new CompressionCodecFactory(conf);
  CompressionCodec codec = ccf.getCodec(new Path("foo.gz"));
  assertTrue("Codec for .gz file is not GzipCodec", 
             codec instanceof GzipCodec);

  // make sure we don't get a null decompressor
  Decompressor codecDecompressor = codec.createDecompressor();
  if (null == codecDecompressor) {
    fail("Got null codecDecompressor");
  }

  // Asking the CodecPool for a decompressor for GzipCodec
  // should not return null
  Decompressor poolDecompressor = CodecPool.getDecompressor(codec);
  if (null == poolDecompressor) {
    fail("Got null poolDecompressor");
  }
  // return a couple decompressors
  CodecPool.returnDecompressor(zlibDecompressor);
  CodecPool.returnDecompressor(poolDecompressor);
  Decompressor poolDecompressor2 = CodecPool.getDecompressor(codec);
  if (poolDecompressor.getClass() == BuiltInGzipDecompressor.class) {
    if (poolDecompressor == poolDecompressor2) {
      fail("Reused java gzip decompressor in pool");
    }
  } else {
    if (poolDecompressor != poolDecompressor2) {
      fail("Did not reuse native gzip decompressor in pool");
    }
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:50,代码来源:TestCodec.java


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