本文整理汇总了Java中org.apache.hadoop.io.compress.zlib.ZlibDecompressor.ZlibDirectDecompressor类的典型用法代码示例。如果您正苦于以下问题:Java ZlibDirectDecompressor类的具体用法?Java ZlibDirectDecompressor怎么用?Java ZlibDirectDecompressor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZlibDirectDecompressor类属于org.apache.hadoop.io.compress.zlib.ZlibDecompressor包,在下文中一共展示了ZlibDirectDecompressor类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compressDecompressLoop
import org.apache.hadoop.io.compress.zlib.ZlibDecompressor.ZlibDirectDecompressor; //导入依赖的package包/类
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());
}
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:40,代码来源:TestZlibCompressorDecompressor.java
示例2: createDirectDecompressor
import org.apache.hadoop.io.compress.zlib.ZlibDecompressor.ZlibDirectDecompressor; //导入依赖的package包/类
@Override
public DirectDecompressor createDirectDecompressor() {
return ZlibFactory.isNativeZlibLoaded(conf)
? new ZlibDecompressor.ZlibDirectDecompressor(
ZlibDecompressor.CompressionHeader.AUTODETECT_GZIP_ZLIB, 0) : null;
}
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:7,代码来源:GzipCodec.java
注:本文中的org.apache.hadoop.io.compress.zlib.ZlibDecompressor.ZlibDirectDecompressor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论