本文整理汇总了Java中org.apache.cassandra.io.compress.ICompressor.WrappedArray类的典型用法代码示例。如果您正苦于以下问题:Java WrappedArray类的具体用法?Java WrappedArray怎么用?Java WrappedArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WrappedArray类属于org.apache.cassandra.io.compress.ICompressor包,在下文中一共展示了WrappedArray类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.apache.cassandra.io.compress.ICompressor.WrappedArray; //导入依赖的package包/类
public void test(byte[] data, int off, int len) throws IOException
{
final int outOffset = 3;
final WrappedArray out = new WrappedArray(new byte[outOffset + compressor.initialCompressedBufferLength(len)]);
new Random().nextBytes(out.buffer);
final int compressedLength = compressor.compress(data, off, len, out, outOffset);
final int restoredOffset = 5;
final byte[] restored = new byte[restoredOffset + len];
new Random().nextBytes(restored);
final int decompressedLength = compressor.uncompress(out.buffer, outOffset, compressedLength, restored, restoredOffset);
assertEquals(decompressedLength, len);
assertArrayEquals(Arrays.copyOfRange(data, off, off + len),
Arrays.copyOfRange(restored, restoredOffset, restoredOffset + decompressedLength));
}