本文整理汇总了Java中org.iq80.snappy.CorruptionException类的典型用法代码示例。如果您正苦于以下问题:Java CorruptionException类的具体用法?Java CorruptionException怎么用?Java CorruptionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CorruptionException类属于org.iq80.snappy包,在下文中一共展示了CorruptionException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compressCharSequence
import org.iq80.snappy.CorruptionException; //导入依赖的package包/类
@NotNull
public static Object compressCharSequence(@NotNull CharSequence string, @NotNull Charset charset) {
if (string.length() < STRING_COMPRESSION_THRESHOLD) {
if (string instanceof CharBuffer && ((CharBuffer)string).capacity() > STRING_COMPRESSION_THRESHOLD) {
string = string.toString(); // shrink to size
}
return string;
}
try {
return Snappy.compress(string.toString().getBytes(charset));
}
catch (CorruptionException ex) {
ex.printStackTrace();
return string;
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CompressionUtil.java
示例2: compressCharSequence
import org.iq80.snappy.CorruptionException; //导入依赖的package包/类
@Nonnull
public static Object compressCharSequence(@Nonnull CharSequence string, @Nonnull Charset charset) {
if (string.length() < STRING_COMPRESSION_THRESHOLD) {
if (string instanceof CharBuffer && ((CharBuffer)string).capacity() > STRING_COMPRESSION_THRESHOLD) {
string = string.toString(); // shrink to size
}
return string;
}
try {
return Snappy.compress(string.toString().getBytes(charset));
}
catch (CorruptionException ex) {
ex.printStackTrace();
return string;
}
}
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:CompressionUtil.java
示例3: decompress
import org.iq80.snappy.CorruptionException; //导入依赖的package包/类
@Override
public byte[] decompress(byte[] input) {
try {
return Snappy.uncompress(input, 0, input.length);
} catch (CorruptionException e) {
throw new CompressionException(e);
}
}
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:SnappyCompressor.java
示例4: getMaybeUncompressedBytes
import org.iq80.snappy.CorruptionException; //导入依赖的package包/类
private byte[] getMaybeUncompressedBytes(@Nullable byte[] bytes) throws SingularityTranscoderException {
if (bytes == null || bytes.length == 0) {
return bytes;
}
try {
return compressLargeDataObjects ? Snappy.uncompress(bytes, 0, bytes.length) : bytes;
} catch (CorruptionException ce) {
throw new SingularityTranscoderException(ce);
}
}
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:13,代码来源:CompressingTranscoder.java
示例5: uncompressCharSequence
import org.iq80.snappy.CorruptionException; //导入依赖的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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:CompressionUtil.java
示例6: compressStringRawBytes
import org.iq80.snappy.CorruptionException; //导入依赖的package包/类
@NotNull
public static Object compressStringRawBytes(@NotNull CharSequence string) {
int length = string.length();
if (length < STRING_COMPRESSION_THRESHOLD) {
if (string instanceof CharBuffer && ((CharBuffer)string).capacity() > STRING_COMPRESSION_THRESHOLD) {
string = string.toString(); // shrink to size
}
return string;
}
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream(length);
@NotNull DataOutput out = new DataOutputStream(bytes);
DataInputOutputUtil.writeINT(out, length);
for (int i=0; i< length;i++) {
char c = string.charAt(i);
DataInputOutputUtil.writeINT(out, c);
}
byte[] compressedBytes = Snappy.compress(bytes.toByteArray());
return compressedBytes.length < length * 2 ? compressedBytes : string;
}
catch (CorruptionException ex) {
ex.printStackTrace();
return string;
}
catch (IOException e) {
e.printStackTrace();
return string;
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:CompressionUtil.java
示例7: uncompressStringRawBytes
import org.iq80.snappy.CorruptionException; //导入依赖的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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:CompressionUtil.java
示例8: uncompressCharSequence
import org.iq80.snappy.CorruptionException; //导入依赖的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);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:CompressionUtil.java
示例9: compressStringRawBytes
import org.iq80.snappy.CorruptionException; //导入依赖的package包/类
@Nonnull
public static Object compressStringRawBytes(@Nonnull CharSequence string) {
int length = string.length();
if (length < STRING_COMPRESSION_THRESHOLD) {
if (string instanceof CharBuffer && ((CharBuffer)string).capacity() > STRING_COMPRESSION_THRESHOLD) {
string = string.toString(); // shrink to size
}
return string;
}
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream(length);
@Nonnull DataOutput out = new DataOutputStream(bytes);
DataInputOutputUtil.writeINT(out, length);
for (int i=0; i< length;i++) {
char c = string.charAt(i);
DataInputOutputUtil.writeINT(out, c);
}
byte[] compressedBytes = Snappy.compress(bytes.toByteArray());
return compressedBytes.length < length * 2 ? compressedBytes : string;
}
catch (CorruptionException ex) {
ex.printStackTrace();
return string;
}
catch (IOException e) {
e.printStackTrace();
return string;
}
}
开发者ID:consulo,项目名称:consulo,代码行数:31,代码来源:CompressionUtil.java
示例10: uncompressStringRawBytes
import org.iq80.snappy.CorruptionException; //导入依赖的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);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:CompressionUtil.java
注:本文中的org.iq80.snappy.CorruptionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论