Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization/Deserialization of avro objects direcly instead of using GenericDatum #13

Open
danikv opened this issue Nov 16, 2018 · 0 comments

Comments

@danikv
Copy link

danikv commented Nov 16, 2018

to use the serialize function we need to convert my avro object into GenericDatum object , and to do that we need to encode the avro object and then decode it. and in order to send we need to decode the genericDatum agian, it feels like we are doing the same thing twice.
avro lib example :

std::auto_ptr<avro::OutputStream> out = avro::memoryOutputStream();
avro::EncoderPtr e = avro::binaryEncoder();
e->init(*out);
c::cpx c1;
c1.re = 100.23;
c1.im = 105.77;
avro::encode(*e, c1);

std::auto_ptr<avro::InputStream> in = avro::memoryInputStream(*out);
avro::DecoderPtr d = avro::binaryDecoder();
d->init(*in);

avro::GenericDatum datum(cpxSchema);
avro::decode(*d, datum);`

instead we can create some global function which look like that :
template<typename T> ssize_t serializeAvro (Schema *schema, const T& avro, std::vector<char> &out, std::string &errstr)
since avro seralize function doesn't use any of the AvroImpl class members , this look better than the current option. any thoughts ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant