Package org.apache.hadoop.io.compress.snappy.SnappyDecompressor

Examples of org.apache.hadoop.io.compress.snappy.SnappyDecompressor.SnappyDirectDecompressor


    case ZLIB_NOHEADER: {
      decompressor = new ZlibDirectDecompressor(CompressionHeader.NO_HEADER, 0);
    }
      break;
    case SNAPPY: {
      decompressor = new SnappyDirectDecompressor();
    }
      break;
    }
    if (decompressor != null) {
      return new DirectDecompressorAdapter(decompressor);
View Full Code Here


    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());
        }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public DirectDecompressor createDirectDecompressor() {
    return isNativeCodeLoaded() ? new SnappyDirectDecompressor() : null;
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.compress.snappy.SnappyDecompressor.SnappyDirectDecompressor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.