Serialization/Deserialization of avro objects direcly instead of using GenericDatum

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp

Research direction

Start by reading the current serialize function and the AvroImpl class, then compare their use of GenericDatum with the Avro encode/decode example in the issue. Clarify whether direct serialization and deserialization should become a public global API, including its schema, output, and error arguments. Done means the proposed API is agreed and its behavior is defined.

Written by the indexing model from the issue text.

Description

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 ?

Dominant language
C
Stars
12
Forks
62
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from confluentinc/libserdes

All issues in confluentinc/libserdes

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.