Search in sources :

Example 16 with TDeserializer

use of org.apache.thrift.TDeserializer in project storm by apache.

the class Utils method thriftDeserialize.

public static <T> T thriftDeserialize(Class<T> c, byte[] b, int offset, int length) {
    try {
        T ret = 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) RT(clojure.lang.RT) AuthorizationException(org.apache.storm.generated.AuthorizationException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ExecuteException(org.apache.commons.exec.ExecuteException) FileNotFoundException(java.io.FileNotFoundException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) ParseException(org.json.simple.parser.ParseException)

Example 17 with TDeserializer

use of org.apache.thrift.TDeserializer in project storm by apache.

the class LocalState method deserializeLatestVersion.

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));
    }
    return result;
}
Also used : TDeserializer(org.apache.thrift.TDeserializer) HashMap(java.util.HashMap) TBase(org.apache.thrift.TBase) HashMap(java.util.HashMap) Map(java.util.Map) ThriftSerializedObject(org.apache.storm.generated.ThriftSerializedObject)

Example 18 with TDeserializer

use of org.apache.thrift.TDeserializer in project hive by apache.

the class JSONMessageFactory method getTableObj.

public static Table getTableObj(ObjectNode jsonTree) throws Exception {
    TDeserializer deSerializer = new TDeserializer(new TJSONProtocol.Factory());
    Table tableObj = new Table();
    String tableJson = jsonTree.get("tableObjJson").asText();
    deSerializer.deserialize(tableObj, tableJson, "UTF-8");
    return tableObj;
}
Also used : TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) TDeserializer(org.apache.thrift.TDeserializer) Table(org.apache.hadoop.hive.metastore.api.Table)

Example 19 with TDeserializer

use of org.apache.thrift.TDeserializer in project hive by apache.

the class MetadataJSONSerializer method deserializePartitionSpec.

@Override
public HCatPartitionSpec deserializePartitionSpec(List<String> hcatPartitionSpecStrings) throws HCatException {
    try {
        List<PartitionSpec> partitionSpecList = new ArrayList<PartitionSpec>();
        TDeserializer deserializer = new TDeserializer(new TJSONProtocol.Factory());
        for (String stringRep : hcatPartitionSpecStrings) {
            PartitionSpec partSpec = new PartitionSpec();
            deserializer.deserialize(partSpec, stringRep, "UTF-8");
            partitionSpecList.add(partSpec);
        }
        return new HCatPartitionSpec(null, PartitionSpecProxy.Factory.get(partitionSpecList));
    } catch (TException deserializationException) {
        throw new HCatException("Failed to deserialize!", deserializationException);
    }
}
Also used : TException(org.apache.thrift.TException) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) TDeserializer(org.apache.thrift.TDeserializer) ArrayList(java.util.ArrayList) HCatException(org.apache.hive.hcatalog.common.HCatException) PartitionSpec(org.apache.hadoop.hive.metastore.api.PartitionSpec)

Example 20 with TDeserializer

use of org.apache.thrift.TDeserializer in project grpc-java by grpc.

the class ThriftUtils method metadataMarshaller.

/** Produce a metadata marshaller. */
public static <T extends TBase<T, ?>> Metadata.BinaryMarshaller<T> metadataMarshaller(final MessageFactory<T> factory) {
    return new Metadata.BinaryMarshaller<T>() {

        @Override
        public byte[] toBytes(T value) {
            try {
                TSerializer serializer = new TSerializer();
                return serializer.serialize(value);
            } catch (TException e) {
                throw Status.INTERNAL.withDescription("Error in serializing Thrift Message").withCause(e).asRuntimeException();
            }
        }

        @Override
        public T parseBytes(byte[] serialized) {
            try {
                TDeserializer deserializer = new TDeserializer();
                T message = factory.newInstance();
                deserializer.deserialize(message, serialized);
                return message;
            } catch (TException e) {
                throw Status.INTERNAL.withDescription("Invalid thrift Byte Sequence").withCause(e).asRuntimeException();
            }
        }
    };
}
Also used : TException(org.apache.thrift.TException) TSerializer(org.apache.thrift.TSerializer) TDeserializer(org.apache.thrift.TDeserializer)

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