Java 类org.apache.hadoop.io.compress.zlib.ZlibDecompressor.ZlibDirectDecompressor 实例源码

项目:hadoop-oss    文件:TestZlibCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = null;
  rawData = generate(rawDataSize);
  ByteArrayOutputStream baos = new ByteArrayOutputStream(rawDataSize+12);
  DeflaterOutputStream dos = new DeflaterOutputStream(baos);
  dos.write(rawData);
  dos.flush();
  dos.close();
  byte[] compressedResult = baos.toByteArray();
  int compressedSize = compressedResult.length;
  ZlibDirectDecompressor decompressor = new ZlibDirectDecompressor();

  ByteBuffer inBuf = ByteBuffer.allocateDirect(compressedSize);
  ByteBuffer outBuf = ByteBuffer.allocateDirect(rawDataSize);

  inBuf.put(compressedResult, 0, compressedSize);
  inBuf.flip();    

  ByteBuffer expected = ByteBuffer.wrap(rawData);

  outBuf.clear();
  while(!decompressor.finished()) {
    decompressor.decompress(inBuf, outBuf);
    if (outBuf.remaining() == 0) {
      outBuf.flip();
      while (outBuf.remaining() > 0) {        
        assertEquals(expected.get(), outBuf.get());
      }
      outBuf.clear();
    }
  }
  outBuf.flip();
  while (outBuf.remaining() > 0) {        
    assertEquals(expected.get(), outBuf.get());
  }
  outBuf.clear();

  assertEquals(0, expected.remaining());
}
项目:hadoop    文件:TestZlibCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = null;
  rawData = generate(rawDataSize);
  ByteArrayOutputStream baos = new ByteArrayOutputStream(rawDataSize+12);
  DeflaterOutputStream dos = new DeflaterOutputStream(baos);
  dos.write(rawData);
  dos.flush();
  dos.close();
  byte[] compressedResult = baos.toByteArray();
  int compressedSize = compressedResult.length;
  ZlibDirectDecompressor decompressor = new ZlibDirectDecompressor();

  ByteBuffer inBuf = ByteBuffer.allocateDirect(compressedSize);
  ByteBuffer outBuf = ByteBuffer.allocateDirect(rawDataSize);

  inBuf.put(compressedResult, 0, compressedSize);
  inBuf.flip();    

  ByteBuffer expected = ByteBuffer.wrap(rawData);

  outBuf.clear();
  while(!decompressor.finished()) {
    decompressor.decompress(inBuf, outBuf);
    if (outBuf.remaining() == 0) {
      outBuf.flip();
      while (outBuf.remaining() > 0) {        
        assertEquals(expected.get(), outBuf.get());
      }
      outBuf.clear();
    }
  }
  outBuf.flip();
  while (outBuf.remaining() > 0) {        
    assertEquals(expected.get(), outBuf.get());
  }
  outBuf.clear();

  assertEquals(0, expected.remaining());
}
项目:aliyun-oss-hadoop-fs    文件:TestZlibCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = null;
  rawData = generate(rawDataSize);
  ByteArrayOutputStream baos = new ByteArrayOutputStream(rawDataSize+12);
  DeflaterOutputStream dos = new DeflaterOutputStream(baos);
  dos.write(rawData);
  dos.flush();
  dos.close();
  byte[] compressedResult = baos.toByteArray();
  int compressedSize = compressedResult.length;
  ZlibDirectDecompressor decompressor = new ZlibDirectDecompressor();

  ByteBuffer inBuf = ByteBuffer.allocateDirect(compressedSize);
  ByteBuffer outBuf = ByteBuffer.allocateDirect(rawDataSize);

  inBuf.put(compressedResult, 0, compressedSize);
  inBuf.flip();    

  ByteBuffer expected = ByteBuffer.wrap(rawData);

  outBuf.clear();
  while(!decompressor.finished()) {
    decompressor.decompress(inBuf, outBuf);
    if (outBuf.remaining() == 0) {
      outBuf.flip();
      while (outBuf.remaining() > 0) {        
        assertEquals(expected.get(), outBuf.get());
      }
      outBuf.clear();
    }
  }
  outBuf.flip();
  while (outBuf.remaining() > 0) {        
    assertEquals(expected.get(), outBuf.get());
  }
  outBuf.clear();

  assertEquals(0, expected.remaining());
}
项目:big-c    文件:TestZlibCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = null;
  rawData = generate(rawDataSize);
  ByteArrayOutputStream baos = new ByteArrayOutputStream(rawDataSize+12);
  DeflaterOutputStream dos = new DeflaterOutputStream(baos);
  dos.write(rawData);
  dos.flush();
  dos.close();
  byte[] compressedResult = baos.toByteArray();
  int compressedSize = compressedResult.length;
  ZlibDirectDecompressor decompressor = new ZlibDirectDecompressor();

  ByteBuffer inBuf = ByteBuffer.allocateDirect(compressedSize);
  ByteBuffer outBuf = ByteBuffer.allocateDirect(rawDataSize);

  inBuf.put(compressedResult, 0, compressedSize);
  inBuf.flip();    

  ByteBuffer expected = ByteBuffer.wrap(rawData);

  outBuf.clear();
  while(!decompressor.finished()) {
    decompressor.decompress(inBuf, outBuf);
    if (outBuf.remaining() == 0) {
      outBuf.flip();
      while (outBuf.remaining() > 0) {        
        assertEquals(expected.get(), outBuf.get());
      }
      outBuf.clear();
    }
  }
  outBuf.flip();
  while (outBuf.remaining() > 0) {        
    assertEquals(expected.get(), outBuf.get());
  }
  outBuf.clear();

  assertEquals(0, expected.remaining());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestZlibCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = null;
  rawData = generate(rawDataSize);
  ByteArrayOutputStream baos = new ByteArrayOutputStream(rawDataSize+12);
  DeflaterOutputStream dos = new DeflaterOutputStream(baos);
  dos.write(rawData);
  dos.flush();
  dos.close();
  byte[] compressedResult = baos.toByteArray();
  int compressedSize = compressedResult.length;
  ZlibDirectDecompressor decompressor = new ZlibDirectDecompressor();

  ByteBuffer inBuf = ByteBuffer.allocateDirect(compressedSize);
  ByteBuffer outBuf = ByteBuffer.allocateDirect(rawDataSize);

  inBuf.put(compressedResult, 0, compressedSize);
  inBuf.flip();    

  ByteBuffer expected = ByteBuffer.wrap(rawData);

  outBuf.clear();
  while(!decompressor.finished()) {
    decompressor.decompress(inBuf, outBuf);
    if (outBuf.remaining() == 0) {
      outBuf.flip();
      while (outBuf.remaining() > 0) {        
        assertEquals(expected.get(), outBuf.get());
      }
      outBuf.clear();
    }
  }
  outBuf.flip();
  while (outBuf.remaining() > 0) {        
    assertEquals(expected.get(), outBuf.get());
  }
  outBuf.clear();

  assertEquals(0, expected.remaining());
}
项目:hops    文件:TestZlibCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = null;
  rawData = generate(rawDataSize);
  ByteArrayOutputStream baos = new ByteArrayOutputStream(rawDataSize+12);
  DeflaterOutputStream dos = new DeflaterOutputStream(baos);
  dos.write(rawData);
  dos.flush();
  dos.close();
  byte[] compressedResult = baos.toByteArray();
  int compressedSize = compressedResult.length;
  ZlibDirectDecompressor decompressor = new ZlibDirectDecompressor();

  ByteBuffer inBuf = ByteBuffer.allocateDirect(compressedSize);
  ByteBuffer outBuf = ByteBuffer.allocateDirect(rawDataSize);

  inBuf.put(compressedResult, 0, compressedSize);
  inBuf.flip();    

  ByteBuffer expected = ByteBuffer.wrap(rawData);

  outBuf.clear();
  while(!decompressor.finished()) {
    decompressor.decompress(inBuf, outBuf);
    if (outBuf.remaining() == 0) {
      outBuf.flip();
      while (outBuf.remaining() > 0) {        
        assertEquals(expected.get(), outBuf.get());
      }
      outBuf.clear();
    }
  }
  outBuf.flip();
  while (outBuf.remaining() > 0) {        
    assertEquals(expected.get(), outBuf.get());
  }
  outBuf.clear();

  assertEquals(0, expected.remaining());
}
项目:hadoop-on-lustre2    文件:TestZlibCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = null;
  rawData = generate(rawDataSize);
  ByteArrayOutputStream baos = new ByteArrayOutputStream(rawDataSize+12);
  DeflaterOutputStream dos = new DeflaterOutputStream(baos);
  dos.write(rawData);
  dos.flush();
  dos.close();
  byte[] compressedResult = baos.toByteArray();
  int compressedSize = compressedResult.length;
  ZlibDirectDecompressor decompressor = new ZlibDirectDecompressor();

  ByteBuffer inBuf = ByteBuffer.allocateDirect(compressedSize);
  ByteBuffer outBuf = ByteBuffer.allocateDirect(rawDataSize);

  inBuf.put(compressedResult, 0, compressedSize);
  inBuf.flip();    

  ByteBuffer expected = ByteBuffer.wrap(rawData);

  outBuf.clear();
  while(!decompressor.finished()) {
    decompressor.decompress(inBuf, outBuf);
    if (outBuf.remaining() == 0) {
      outBuf.flip();
      while (outBuf.remaining() > 0) {        
        assertEquals(expected.get(), outBuf.get());
      }
      outBuf.clear();
    }
  }
  outBuf.flip();
  while (outBuf.remaining() > 0) {        
    assertEquals(expected.get(), outBuf.get());
  }
  outBuf.clear();

  assertEquals(0, expected.remaining());
}
项目:hadoop-oss    文件:GzipCodec.java   
@Override
public DirectDecompressor createDirectDecompressor() {
  return ZlibFactory.isNativeZlibLoaded(conf) 
      ? new ZlibDecompressor.ZlibDirectDecompressor(
        ZlibDecompressor.CompressionHeader.AUTODETECT_GZIP_ZLIB, 0) : null;
}
项目:hadoop    文件:GzipCodec.java   
@Override
public DirectDecompressor createDirectDecompressor() {
  return ZlibFactory.isNativeZlibLoaded(conf) 
      ? new ZlibDecompressor.ZlibDirectDecompressor(
        ZlibDecompressor.CompressionHeader.AUTODETECT_GZIP_ZLIB, 0) : null;
}
项目:aliyun-oss-hadoop-fs    文件:GzipCodec.java   
@Override
public DirectDecompressor createDirectDecompressor() {
  return ZlibFactory.isNativeZlibLoaded(conf) 
      ? new ZlibDecompressor.ZlibDirectDecompressor(
        ZlibDecompressor.CompressionHeader.AUTODETECT_GZIP_ZLIB, 0) : null;
}
项目:big-c    文件:GzipCodec.java   
@Override
public DirectDecompressor createDirectDecompressor() {
  return ZlibFactory.isNativeZlibLoaded(conf) 
      ? new ZlibDecompressor.ZlibDirectDecompressor(
        ZlibDecompressor.CompressionHeader.AUTODETECT_GZIP_ZLIB, 0) : null;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:GzipCodec.java   
@Override
public DirectDecompressor createDirectDecompressor() {
  return ZlibFactory.isNativeZlibLoaded(conf) 
      ? new ZlibDecompressor.ZlibDirectDecompressor(
        ZlibDecompressor.CompressionHeader.AUTODETECT_GZIP_ZLIB, 0) : null;
}
项目:hops    文件:GzipCodec.java   
@Override
public DirectDecompressor createDirectDecompressor() {
  return ZlibFactory.isNativeZlibLoaded(conf) 
      ? new ZlibDecompressor.ZlibDirectDecompressor(
        ZlibDecompressor.CompressionHeader.AUTODETECT_GZIP_ZLIB, 0) : null;
}
项目:hadoop-on-lustre2    文件:GzipCodec.java   
@Override
public DirectDecompressor createDirectDecompressor() {
  return ZlibFactory.isNativeZlibLoaded(conf) 
      ? new ZlibDecompressor.ZlibDirectDecompressor(
        ZlibDecompressor.CompressionHeader.AUTODETECT_GZIP_ZLIB, 0) : null;
}