Search in sources :

Example 26 with TDeserializer

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);
    }
}
Also used : TDeserializer(org.apache.thrift.TDeserializer) ExecuteException(org.apache.commons.exec.ExecuteException) TException(org.apache.thrift.TException) IOException(java.io.IOException)

Example 27 with TDeserializer

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;
}
Also used : TDeserializer(org.apache.thrift.TDeserializer)

Example 28 with TDeserializer

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;
}
Also used : TDeserializer(org.apache.thrift.TDeserializer) IOException(java.io.IOException)

Example 29 with TDeserializer

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;
}
Also used : Path(java.nio.file.Path) TDeserializer(org.apache.thrift.TDeserializer) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) Example(com.airbnb.aerosolve.core.Example) URL(java.net.URL)

Example 30 with TDeserializer

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;
}
Also used : TException(org.apache.thrift.TException) TDeserializer(org.apache.thrift.TDeserializer) TBinaryProtocol(org.apache.cassandra.thrift.TBinaryProtocol) SlicePredicate(org.apache.cassandra.thrift.SlicePredicate)

Aggregations

TDeserializer (org.apache.thrift.TDeserializer)30 TException (org.apache.thrift.TException)19 IOException (java.io.IOException)8 TBase (org.apache.thrift.TBase)6 Table (org.apache.hadoop.hive.metastore.api.Table)4 TBinaryProtocol (org.apache.cassandra.thrift.TBinaryProtocol)3 HCatException (org.apache.hive.hcatalog.common.HCatException)3 ThriftSerializedObject (org.apache.storm.generated.ThriftSerializedObject)3 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)3 LoggerFactory (org.slf4j.LoggerFactory)3 RT (clojure.lang.RT)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 SlicePredicate (org.apache.cassandra.thrift.SlicePredicate)2 ExecuteException (org.apache.commons.exec.ExecuteException)2 Partition (org.apache.hadoop.hive.metastore.api.Partition)2 ParseException (org.json.simple.parser.ParseException)2 Example (com.airbnb.aerosolve.core.Example)1 AgentStatMemoryGcBo (com.navercorp.pinpoint.common.server.bo.AgentStatMemoryGcBo)1