use of org.apache.thrift.TDeserializer in project jstorm by alibaba.
the class JStormUtils 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);
}
}
use of org.apache.thrift.TDeserializer in project jstorm by alibaba.
the class JStormUtils 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 aerosolve by airbnb.
the class Util method decode.
public static <T extends TBase> T decode(T base, String str) {
try {
byte[] bytes = Base64.decodeBase64(str.getBytes());
TDeserializer deserializer = new TDeserializer();
deserializer.deserialize(base, bytes);
} catch (Exception e) {
e.printStackTrace();
}
return base;
}
use of org.apache.thrift.TDeserializer in project aerosolve by airbnb.
the class Debug method loadExampleFromResource.
/*
loadExampleFromResource read example from resources folder, i.e. test/resources
use it on unit test to load example from disk
*/
public static Example loadExampleFromResource(String name) {
URL url = Debug.class.getResource("/" + name);
try {
Path path = Paths.get(url.toURI());
byte[] bytes = Files.readAllBytes(path);
TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
Example example = new Example();
deserializer.deserialize(example, bytes);
return example;
} catch (Exception e) {
e.printStackTrace();
}
assert (false);
return null;
}
use of org.apache.thrift.TDeserializer in project eiger by wlloyd.
the class ConfigHelper method predicateFromString.
private static SlicePredicate predicateFromString(String st) {
assert st != null;
TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
SlicePredicate predicate = new SlicePredicate();
try {
deserializer.deserialize(predicate, Hex.hexToBytes(st));
} catch (TException e) {
throw new RuntimeException(e);
}
return predicate;
}
Aggregations