本文整理汇总了Java中org.iq80.snappy.Snappy.getUncompressedLength方法的典型用法代码示例。如果您正苦于以下问题:Java Snappy.getUncompressedLength方法的具体用法?Java Snappy.getUncompressedLength怎么用?Java Snappy.getUncompressedLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.iq80.snappy.Snappy
的用法示例。
在下文中一共展示了Snappy.getUncompressedLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decompress
import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
public void decompress(byte[] value, int offset, int len) {
if (value[offset] == 0) {
grow(Snappy.getUncompressedLength(value, offset + 1));
end = Snappy.uncompress(value, offset + 1, len - 1, buffer, 0);
} else {
int s = Utils.decodeInt(value, offset + 1);
// Calculate uncompress size
offset += 5;
len -= 5;
int un_s = Snappy.getUncompressedLength(value, offset);
un_s += Snappy.getUncompressedLength(value, offset + s);
grow(un_s);
end = Snappy.uncompress(value, offset, s, buffer, 0);
end += Snappy.uncompress(value, offset + s, len - s, buffer, end);
}
}
示例2: uncompressCharSequence
import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@NotNull
public static CharSequence uncompressCharSequence(@NotNull Object string, @NotNull Charset charset) {
if (string instanceof CharSequence) return (CharSequence)string;
byte[] b = (byte[])string;
try {
int uncompressedLength = Snappy.getUncompressedLength(b, 0);
byte[] bytes = spareBufferLocal.getBuffer(uncompressedLength);
int bytesLength = Snappy.uncompress(b, 0, b.length, bytes, 0);
return new String(bytes, 0, bytesLength, charset);
}
catch (CorruptionException ex) {
throw new RuntimeException(ex);
}
}
示例3: uncompressStringRawBytes
import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@NotNull
public static CharSequence uncompressStringRawBytes(@NotNull Object compressed) {
if (compressed instanceof CharSequence) return (CharSequence)compressed;
byte[] b = (byte[])compressed;
try {
int uncompressedLength = Snappy.getUncompressedLength(b, 0);
byte[] bytes = spareBufferLocal.getBuffer(uncompressedLength);
int bytesLength = Snappy.uncompress(b, 0, b.length, bytes, 0);
ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes, 0, bytesLength);
@NotNull DataInput in = new DataInputStream(byteStream);
int len = DataInputOutputUtil.readINT(in);
char[] chars = new char[len];
for (int i=0; i<len; i++) {
int c = DataInputOutputUtil.readINT(in);
chars[i] = (char)c;
}
return StringFactory.createShared(chars);
}
catch (CorruptionException ex) {
throw new RuntimeException(ex);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
示例4: decompressSnappy
import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
private int decompressSnappy(Slice in)
throws IOException
{
byte[] inArray = (byte[]) in.getBase();
int inOffset = (int) (in.getAddress() - ARRAY_BYTE_BASE_OFFSET);
int inLength = in.length();
int uncompressedLength = Snappy.getUncompressedLength(inArray, inOffset);
checkArgument(uncompressedLength <= maxBufferSize, "Snappy requires buffer (%s) larger than max size (%s)", uncompressedLength, maxBufferSize);
allocateOrGrowBuffer(uncompressedLength, false);
return Snappy.uncompress(inArray, inOffset, inLength, buffer, 0);
}
示例5: uncompressCharSequence
import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@Nonnull
public static CharSequence uncompressCharSequence(@Nonnull Object string, @Nonnull Charset charset) {
if (string instanceof CharSequence) return (CharSequence)string;
byte[] b = (byte[])string;
try {
int uncompressedLength = Snappy.getUncompressedLength(b, 0);
byte[] bytes = spareBufferLocal.getBuffer(uncompressedLength);
int bytesLength = Snappy.uncompress(b, 0, b.length, bytes, 0);
return new String(bytes, 0, bytesLength, charset);
}
catch (CorruptionException ex) {
throw new RuntimeException(ex);
}
}
示例6: uncompressStringRawBytes
import org.iq80.snappy.Snappy; //导入方法依赖的package包/类
@Nonnull
public static CharSequence uncompressStringRawBytes(@Nonnull Object compressed) {
if (compressed instanceof CharSequence) return (CharSequence)compressed;
byte[] b = (byte[])compressed;
try {
int uncompressedLength = Snappy.getUncompressedLength(b, 0);
byte[] bytes = spareBufferLocal.getBuffer(uncompressedLength);
int bytesLength = Snappy.uncompress(b, 0, b.length, bytes, 0);
ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes, 0, bytesLength);
@Nonnull DataInput in = new DataInputStream(byteStream);
int len = DataInputOutputUtil.readINT(in);
char[] chars = new char[len];
for (int i=0; i<len; i++) {
int c = DataInputOutputUtil.readINT(in);
chars[i] = (char)c;
}
return StringFactory.createShared(chars);
}
catch (CorruptionException ex) {
throw new RuntimeException(ex);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}