Java 类org.apache.hadoop.io.compress.snappy.SnappyDecompressor.SnappyDirectDecompressor 实例源码

项目:hadoop-oss    文件:TestSnappyCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = BytesGenerator.get(rawDataSize);    
  byte[] compressedResult = new byte[rawDataSize+20];
  int directBufferSize = Math.max(rawDataSize*2, 64*1024);    
  SnappyCompressor compressor = new SnappyCompressor(directBufferSize);
  compressor.setInput(rawData, 0, rawDataSize);
  int compressedSize = compressor.compress(compressedResult, 0, compressedResult.length);
  SnappyDirectDecompressor decompressor = new SnappyDirectDecompressor();

  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    文件:TestSnappyCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = BytesGenerator.get(rawDataSize);    
  byte[] compressedResult = new byte[rawDataSize+20];
  int directBufferSize = Math.max(rawDataSize*2, 64*1024);    
  SnappyCompressor compressor = new SnappyCompressor(directBufferSize);
  compressor.setInput(rawData, 0, rawDataSize);
  int compressedSize = compressor.compress(compressedResult, 0, compressedResult.length);
  SnappyDirectDecompressor decompressor = new SnappyDirectDecompressor();

  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    文件:TestSnappyCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = BytesGenerator.get(rawDataSize);    
  byte[] compressedResult = new byte[rawDataSize+20];
  int directBufferSize = Math.max(rawDataSize*2, 64*1024);    
  SnappyCompressor compressor = new SnappyCompressor(directBufferSize);
  compressor.setInput(rawData, 0, rawDataSize);
  int compressedSize = compressor.compress(compressedResult, 0, compressedResult.length);
  SnappyDirectDecompressor decompressor = new SnappyDirectDecompressor();

  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    文件:TestSnappyCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = BytesGenerator.get(rawDataSize);    
  byte[] compressedResult = new byte[rawDataSize+20];
  int directBufferSize = Math.max(rawDataSize*2, 64*1024);    
  SnappyCompressor compressor = new SnappyCompressor(directBufferSize);
  compressor.setInput(rawData, 0, rawDataSize);
  int compressedSize = compressor.compress(compressedResult, 0, compressedResult.length);
  SnappyDirectDecompressor decompressor = new SnappyDirectDecompressor();

  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    文件:TestSnappyCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = BytesGenerator.get(rawDataSize);    
  byte[] compressedResult = new byte[rawDataSize+20];
  int directBufferSize = Math.max(rawDataSize*2, 64*1024);    
  SnappyCompressor compressor = new SnappyCompressor(directBufferSize);
  compressor.setInput(rawData, 0, rawDataSize);
  int compressedSize = compressor.compress(compressedResult, 0, compressedResult.length);
  SnappyDirectDecompressor decompressor = new SnappyDirectDecompressor();

  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    文件:TestSnappyCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = BytesGenerator.get(rawDataSize);    
  byte[] compressedResult = new byte[rawDataSize+20];
  int directBufferSize = Math.max(rawDataSize*2, 64*1024);    
  SnappyCompressor compressor = new SnappyCompressor(directBufferSize);
  compressor.setInput(rawData, 0, rawDataSize);
  int compressedSize = compressor.compress(compressedResult, 0, compressedResult.length);
  SnappyDirectDecompressor decompressor = new SnappyDirectDecompressor();

  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    文件:TestSnappyCompressorDecompressor.java   
private void compressDecompressLoop(int rawDataSize) throws IOException {
  byte[] rawData = BytesGenerator.get(rawDataSize);    
  byte[] compressedResult = new byte[rawDataSize+20];
  int directBufferSize = Math.max(rawDataSize*2, 64*1024);    
  SnappyCompressor compressor = new SnappyCompressor(directBufferSize);
  compressor.setInput(rawData, 0, rawDataSize);
  int compressedSize = compressor.compress(compressedResult, 0, compressedResult.length);
  SnappyDirectDecompressor decompressor = new SnappyDirectDecompressor();

  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    文件:SnappyCodec.java   
/**
 * {@inheritDoc}
 */
@Override
public DirectDecompressor createDirectDecompressor() {
  return isNativeCodeLoaded() ? new SnappyDirectDecompressor() : null;
}
项目:hadoop    文件:SnappyCodec.java   
/**
 * {@inheritDoc}
 */
@Override
public DirectDecompressor createDirectDecompressor() {
  return isNativeCodeLoaded() ? new SnappyDirectDecompressor() : null;
}
项目:aliyun-oss-hadoop-fs    文件:SnappyCodec.java   
/**
 * {@inheritDoc}
 */
@Override
public DirectDecompressor createDirectDecompressor() {
  return isNativeCodeLoaded() ? new SnappyDirectDecompressor() : null;
}
项目:big-c    文件:SnappyCodec.java   
/**
 * {@inheritDoc}
 */
@Override
public DirectDecompressor createDirectDecompressor() {
  return isNativeCodeLoaded() ? new SnappyDirectDecompressor() : null;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:SnappyCodec.java   
/**
 * {@inheritDoc}
 */
@Override
public DirectDecompressor createDirectDecompressor() {
  return isNativeCodeLoaded() ? new SnappyDirectDecompressor() : null;
}
项目:hops    文件:SnappyCodec.java   
/**
 * {@inheritDoc}
 */
@Override
public DirectDecompressor createDirectDecompressor() {
  return isNativeCodeLoaded() ? new SnappyDirectDecompressor() : null;
}
项目:hadoop-on-lustre2    文件:SnappyCodec.java   
/**
 * {@inheritDoc}
 */
@Override
public DirectDecompressor createDirectDecompressor() {
  return isNativeCodeLoaded() ? new SnappyDirectDecompressor() : null;
}