use of org.apache.thrift.TDeserializer in project brisk by riptano.
the class CassandraStorage method cfdefFromString.
private static CfDef cfdefFromString(String st) {
assert st != null;
TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
CfDef cfDef = new CfDef();
try {
deserializer.deserialize(cfDef, FBUtilities.hexToBytes(st));
} catch (TException e) {
throw new RuntimeException(e);
}
return cfDef;
}
use of org.apache.thrift.TDeserializer in project jstorm by alibaba.
the class GzipThriftSerializationDelegate method deserialize.
@Override
public <T> T deserialize(byte[] bytes, Class<T> clazz) {
try {
TBase instance = (TBase) clazz.newInstance();
new TDeserializer().deserialize(instance, Utils.gunzip(bytes));
return (T) instance;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.thrift.TDeserializer in project jstorm by alibaba.
the class Utils method getDes.
private static TDeserializer getDes() {
TDeserializer des = threadDes.get();
if (des == null) {
des = new TDeserializer();
threadDes.set(des);
}
return des;
}
use of org.apache.thrift.TDeserializer in project jstorm by alibaba.
the class ThriftSerializationDelegate method deserialize.
@Override
public <T> T deserialize(byte[] bytes, Class<T> clazz) {
try {
TBase instance = (TBase) clazz.newInstance();
new TDeserializer().deserialize(instance, bytes);
return (T) instance;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.thrift.TDeserializer in project jstorm by alibaba.
the class Utils method thriftDeserialize.
public static <T> T thriftDeserialize(Class c, byte[] b, int offset, int length) {
try {
T ret = (T) c.newInstance();
TDeserializer des = getDes();
des.deserialize((TBase) ret, b, offset, length);
return ret;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations