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


Java Compression.decompress方法代码示例

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


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

示例1: prepareDecoding

import org.apache.hadoop.hbase.io.compress.Compression; //导入方法依赖的package包/类
@Override
public void prepareDecoding(int onDiskSizeWithoutHeader, int uncompressedSizeWithoutHeader,
    ByteBuffer blockBufferWithoutHeader, byte[] onDiskBlock, int offset) throws IOException {
  InputStream in = new DataInputStream(new ByteArrayInputStream(onDiskBlock, offset,
    onDiskSizeWithoutHeader));

  Encryption.Context cryptoContext = fileContext.getEncryptionContext();
  if (cryptoContext != Encryption.Context.NONE) {

    Cipher cipher = cryptoContext.getCipher();
    Decryptor decryptor = cipher.getDecryptor();
    decryptor.setKey(cryptoContext.getKey());

    // Encrypted block format:
    // +--------------------------+
    // | byte iv length           |
    // +--------------------------+
    // | iv data ...              |
    // +--------------------------+
    // | encrypted block data ... |
    // +--------------------------+

    int ivLength = in.read();
    if (ivLength > 0) {
      byte[] iv = new byte[ivLength];
      IOUtils.readFully(in, iv);
      decryptor.setIv(iv);
      // All encrypted blocks will have a nonzero IV length. If we see an IV
      // length of zero, this means the encoding context had 0 bytes of
      // plaintext to encode.
      decryptor.reset();
      in = decryptor.createDecryptionStream(in);
    }
    onDiskSizeWithoutHeader -= Bytes.SIZEOF_BYTE + ivLength;
  }

  Compression.Algorithm compression = fileContext.getCompression();
  if (compression != Compression.Algorithm.NONE) {
    Compression.decompress(blockBufferWithoutHeader.array(),
      blockBufferWithoutHeader.arrayOffset(), in, onDiskSizeWithoutHeader,
      uncompressedSizeWithoutHeader, compression);
  } else {
    IOUtils.readFully(in, blockBufferWithoutHeader.array(),
      blockBufferWithoutHeader.arrayOffset(), onDiskSizeWithoutHeader);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:47,代码来源:HFileBlockDefaultDecodingContext.java


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