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());
}
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);
}
}
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();
}
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);
}
}
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);
}
}
Aggregations