You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Peter Cameron <pe...@2icworld.com> on 2012/06/18 16:24:55 UTC
C# version of Avro and reflection
In my Java work I successfully use Avro to serialise and deserialise
objects for which I only have the schema. There are no Avro objects
generated from these schemas because we only have the schemas at
runtime, and no code generation was done. So for example, the following
Java satisifies our functionality (the value is always a ByteBuffer of
bytes by the way):
private Object deserialiseComplex(final Object value, final Schema
schema) throws IOException, ClassNotFoundException {
final byte [] bytes = ((ByteBuffer) value).array();
final ByteArrayInputStream in = new ByteArrayInputStream(bytes);
final BinaryDecoder decoder =
DecoderFactory.get().binaryDecoder(in, null);
final ReflectDatumReader<Object> reader = new
ReflectDatumReader<>(schema);
final Object deserialised = reader.read(null, decoder);
return deserialised;
}
However, some colleagues are developing a C# version of my application
and have found that C# Avro provides no reflective capabilities like
ReflectDatumReader and ReflectDatumWriter.
Is the only way to have the same functionality on the C# side to
generate Avro objects from the schemas and hence use the Specific
readers and writers?
Peter