Example usage for org.apache.thrift TDeserializer TDeserializer

List of usage examples for org.apache.thrift TDeserializer TDeserializer

Introduction

In this page you can find the example usage for org.apache.thrift TDeserializer TDeserializer.

Prototype

public TDeserializer() 

Source Link

Document

Create a new TDeserializer that uses the TBinaryProtocol by default.

Usage

From source file:org.apache.storm.utils.LocalState.java

License:Apache License

private Map<String, TBase> deserializeLatestVersion() throws IOException {
    Map<String, TBase> result = new HashMap<>();
    TDeserializer td = new TDeserializer();
    for (Map.Entry<String, ThriftSerializedObject> ent : partialDeserializeLatestVersion(td).entrySet()) {
        result.put(ent.getKey(), deserialize(ent.getValue(), td));
    }/*from w  ww . j  a  va2  s. c  om*/
    return result;
}

From source file:org.apache.storm.utils.LocalState.java

License:Apache License

private Map<String, ThriftSerializedObject> partialDeserializeLatestVersion(TDeserializer td) {
    try {/*from  w  w  w. j  av  a 2 s.c o m*/
        String latestPath = _vs.mostRecentVersionPath();
        Map<String, ThriftSerializedObject> result = new HashMap<>();
        if (latestPath != null) {
            byte[] serialized = FileUtils.readFileToByteArray(new File(latestPath));
            if (serialized.length == 0) {
                LOG.warn("LocalState file '{}' contained no data, resetting state", latestPath);
            } else {
                if (td == null) {
                    td = new TDeserializer();
                }
                LocalStateData data = new LocalStateData();
                td.deserialize(data, serialized);
                result = data.get_serialized_parts();
            }
        }
        return result;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.apache.storm.utils.Utils.java

License:Apache License

private static TDeserializer getDes() {
    TDeserializer des = threadDes.get();
    if (des == null) {
        des = new TDeserializer();
        threadDes.set(des);//from  ww w  .  j a va2s .  c  o m
    }
    return des;
}

From source file:org.jhk.pulsing.pail.thrift.AbstractThriftPailStructure.java

License:Apache License

private synchronized TDeserializer getDeserializer() {
    if (deserializer == null) {
        _LOGGER.debug("AbstractThriftPailStructure.getDeserializer");
        deserializer = new TDeserializer();
    }/*w ww. ja v a  2s. co  m*/
    return deserializer;
}

From source file:org.springframework.obm.thrift.ThriftMarshaller.java

License:Apache License

@Override
public void afterPropertiesSet() throws Exception {
    if (serializer == null) {
        this.serializer = new TSerializer();
    }/*ww  w.j  av a2  s .  co  m*/

    if (deserializer == null) {
        this.deserializer = new TDeserializer();
    }
}

From source file:storm.trident.util.TridentUtils.java

License:Apache License

public static <T> T thriftDeserialize(Class c, byte[] b) {
    try {// w  w w  .  j  ava 2 s  .  c  o  m
        T ret = (T) c.newInstance();
        TDeserializer des = threadDes.get();
        if (des == null) {
            des = new TDeserializer();
            threadDes.set(des);
        }
        des.deserialize((TBase) ret, b);
        return ret;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

}