Search in sources :

Example 26 with TSerializer

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

the class PartitionSerializer method writeTo.

@Override
public void writeTo(JsonWriter writer, ReplicationSpec additionalPropertiesProvider) throws SemanticException, IOException {
    try {
        TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
        // Remove all the entries from the parameters which are added by repl tasks internally.
        Map<String, String> parameters = partition.getParameters();
        if (parameters != null) {
            parameters.entrySet().removeIf(e -> e.getKey().equals(ReplUtils.REPL_CHECKPOINT_KEY));
        }
        if (additionalPropertiesProvider.isInReplicationScope()) {
            // Event replication State will be null in case of bootstrap dump.
            if (additionalPropertiesProvider.getReplSpecType() != ReplicationSpec.Type.INCREMENTAL_DUMP) {
                partition.putToParameters(ReplicationSpec.KEY.CURR_STATE_ID_SOURCE.toString(), additionalPropertiesProvider.getCurrentReplicationState());
            }
        }
        writer.jsonGenerator.writeString(serializer.toString(partition));
        writer.jsonGenerator.flush();
    } catch (TException e) {
        throw new SemanticException(ErrorMsg.ERROR_SERIALIZE_METASTORE.getMsg(), e);
    }
}
Also used : TException(org.apache.thrift.TException) TSerializer(org.apache.thrift.TSerializer) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException)

Example 27 with TSerializer

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

the class MessageBuilder method createTableObjJson.

public static String createTableObjJson(Table tableObj) throws TException {
    // Note: The parameters of the Table object will be removed in the filter if it matches
    // any pattern provided through EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS
    filterMapkeys(tableObj.getParameters(), paramsFilter);
    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
    return serializer.toString(tableObj);
}
Also used : TSerializer(org.apache.thrift.TSerializer) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol)

Example 28 with TSerializer

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

the class MessageBuilder method createPartitionObjJson.

public static String createPartitionObjJson(Partition partitionObj) throws TException {
    // Note: The parameters of the Partition object will be removed in the filter if it matches
    // any pattern provided through EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS
    filterMapkeys(partitionObj.getParameters(), paramsFilter);
    TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
    return serializer.toString(partitionObj);
}
Also used : TSerializer(org.apache.thrift.TSerializer) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol)

Example 29 with TSerializer

use of org.apache.thrift.TSerializer in project vcell by virtualcell.

the class VisMeshUtils method writeFiniteVolumeIndexData.

static void writeFiniteVolumeIndexData(File finiteVolumeIndexFile, FiniteVolumeIndexData finiteVolumeIndexData) throws IOException {
    TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
    try {
        byte[] blob = serializer.serialize(finiteVolumeIndexData);
        FileUtils.writeByteArrayToFile(finiteVolumeIndexFile, blob);
    } catch (TException e) {
        e.printStackTrace();
        throw new IOException("error writing FiniteVolumeIndexData to file " + finiteVolumeIndexFile.getPath() + ": " + e.getMessage(), e);
    }
}
Also used : TException(org.apache.thrift.TException) TSerializer(org.apache.thrift.TSerializer) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) IOException(java.io.IOException)

Example 30 with TSerializer

use of org.apache.thrift.TSerializer in project vcell by virtualcell.

the class VisMeshUtils method writeVisMesh.

static void writeVisMesh(File visMeshFile, VisMesh visMesh) throws IOException {
    TSerializer serializer = new TSerializer(new TBinaryProtocol.Factory());
    try {
        byte[] blob = serializer.serialize(visMesh);
        FileUtils.writeByteArrayToFile(visMeshFile, blob);
    } catch (TException e) {
        e.printStackTrace();
        throw new IOException("error writing VisMesh to file " + visMeshFile.getPath() + ": " + e.getMessage(), e);
    }
}
Also used : TException(org.apache.thrift.TException) TSerializer(org.apache.thrift.TSerializer) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) IOException(java.io.IOException)

Aggregations

TSerializer (org.apache.thrift.TSerializer)35 TException (org.apache.thrift.TException)19 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)14 IOException (java.io.IOException)12 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)8 Test (org.junit.Test)6 TDeserializer (org.apache.thrift.TDeserializer)5 ArrayList (java.util.ArrayList)4 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)4 OptRun (org.vcell.optimization.thrift.OptRun)4 Table (org.apache.hadoop.hive.metastore.api.Table)3 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)3 VCellApiClient (org.vcell.api.client.VCellApiClient)3 OptProblem (org.vcell.optimization.thrift.OptProblem)3 OptRunStatus (org.vcell.optimization.thrift.OptRunStatus)3 MathException (cbit.vcell.math.MathException)2 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)2 OptSolverResultSet (cbit.vcell.opt.OptSolverResultSet)2 OptRunResultSet (cbit.vcell.opt.OptSolverResultSet.OptRunResultSet)2 OptimizationException (cbit.vcell.opt.OptimizationException)2