use of voldemort.serialization.SerializationException in project voldemort by voldemort.
the class AvroSpecificSerializer method toObject.
public T toObject(byte[] bytes) {
Decoder decoder = DecoderFactory.defaultFactory().createBinaryDecoder(bytes, null);
SpecificDatumReader<T> reader = null;
try {
reader = new SpecificDatumReader<T>(clazz);
return reader.read(null, decoder);
} catch (IOException e) {
throw new SerializationException(e);
}
}
use of voldemort.serialization.SerializationException in project voldemort by voldemort.
the class AvroSpecificSerializer method toBytes.
public byte[] toBytes(T object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
Encoder encoder = new BinaryEncoder(output);
SpecificDatumWriter<T> datumWriter = null;
try {
datumWriter = new SpecificDatumWriter<T>(clazz);
datumWriter.write(object, encoder);
encoder.flush();
} catch (IOException e) {
throw new SerializationException(e);
} finally {
SerializationUtils.close(output);
}
return output.toByteArray();
}
Aggregations