Search in sources :

Example 16 with SerializationException

use of voldemort.serialization.SerializationException in project voldemort by voldemort.

the class JsonTypeSerializer method toObject.

public Object toObject(DataInputStream input) throws IOException {
    Integer version = 0;
    if (hasVersion)
        version = Integer.valueOf(input.readByte());
    JsonTypeDefinition typeDef = typeDefVersions.get(version);
    if (typeDef == null)
        throw new SerializationException("No schema found for schema version " + version + ".");
    return read(input, typeDef.getType());
}
Also used : SerializationException(voldemort.serialization.SerializationException)

Example 17 with SerializationException

use of voldemort.serialization.SerializationException in project voldemort by voldemort.

the class JsonTypeSerializer method toBytes.

public byte[] toBytes(Object object) {
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream output = new DataOutputStream(bytes);
    try {
        toBytes(object, output);
        output.flush();
        return bytes.toByteArray();
    } catch (IOException e) {
        throw new SerializationException(e);
    }
}
Also used : SerializationException(voldemort.serialization.SerializationException) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 18 with SerializationException

use of voldemort.serialization.SerializationException in project voldemort by voldemort.

the class AvroGenericSerializer method toBytes.

public byte[] toBytes(Object object) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    Encoder encoder = new BinaryEncoder(output);
    GenericDatumWriter<Object> datumWriter = null;
    try {
        datumWriter = new GenericDatumWriter<Object>(typeDef);
        datumWriter.write(object, encoder);
        encoder.flush();
    } catch (IOException e) {
        throw new SerializationException(e);
    } finally {
        SerializationUtils.close(output);
    }
    return output.toByteArray();
}
Also used : SerializationException(voldemort.serialization.SerializationException) BinaryEncoder(org.apache.avro.io.BinaryEncoder) BinaryEncoder(org.apache.avro.io.BinaryEncoder) Encoder(org.apache.avro.io.Encoder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 19 with SerializationException

use of voldemort.serialization.SerializationException in project voldemort by voldemort.

the class AvroGenericSerializer method toObject.

public Object toObject(byte[] bytes) {
    Decoder decoder = DecoderFactory.defaultFactory().createBinaryDecoder(bytes, null);
    GenericDatumReader<Object> reader = null;
    try {
        reader = new GenericDatumReader<Object>(typeDef);
        return reader.read(null, decoder);
    } catch (IOException e) {
        throw new SerializationException(e);
    }
}
Also used : SerializationException(voldemort.serialization.SerializationException) IOException(java.io.IOException) Decoder(org.apache.avro.io.Decoder)

Example 20 with SerializationException

use of voldemort.serialization.SerializationException in project voldemort by voldemort.

the class AvroReflectiveSerializer method toObject.

public T toObject(byte[] bytes) {
    Decoder decoder = DecoderFactory.defaultFactory().createBinaryDecoder(bytes, null);
    ReflectDatumReader<T> reader = null;
    try {
        reader = new ReflectDatumReader<T>(clazz);
        return reader.read(null, decoder);
    } catch (IOException e) {
        throw new SerializationException(e);
    }
}
Also used : SerializationException(voldemort.serialization.SerializationException) IOException(java.io.IOException) Decoder(org.apache.avro.io.Decoder)

Aggregations

SerializationException (voldemort.serialization.SerializationException)22 IOException (java.io.IOException)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 BinaryEncoder (org.apache.avro.io.BinaryEncoder)5 Encoder (org.apache.avro.io.Encoder)5 Decoder (org.apache.avro.io.Decoder)4 Schema (org.apache.avro.Schema)3 ByteArray (voldemort.utils.ByteArray)3 Versioned (voldemort.versioning.Versioned)3 BufferedWriter (java.io.BufferedWriter)2 OutputStreamWriter (java.io.OutputStreamWriter)2 StringReader (java.io.StringReader)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 TException (org.apache.thrift.TException)2 TProtocol (org.apache.thrift.protocol.TProtocol)2 Node (voldemort.cluster.Node)2 Serializer (voldemort.serialization.Serializer)2 SerializerDefinition (voldemort.serialization.SerializerDefinition)2