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