You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Purushotham Nayak <pu...@gmail.com> on 2019/12/13 01:09:30 UTC

Making C++ implementation same as std

Hi Everyone,

There are a few changes I wanted to make to the C++ implementation and make
compatible with std (and asio) streams as well as update it to use
C++11/14. I wanted to see what other thought. I would be happy to make the
change. I already have an implementation along these lines.

Currently, we use the output stream like this:

std::auto_ptr<avro::OutputStream> out =
avro::fileOutputStream("complex.dat", 4096);
avro::EncoderPtr e = avro::binaryEncoder();
e->init(*out);
c::cpx c1;
c1.re = 1.0;
c1.im = 2.13;
avro::encode(*e, c1);

Instead we should able to do like this:

avro::ostream os("complex.dat", ios_base::binary); // avro binary stream
c::cpx c1;
c1.re = 1.0;
c1.im = 2.13;
os << c1;

In other words, it should work similar to std stream. The use of
ios_base::binary or not decides whether this is a binary / json stream. The
implementation of the encoder/buffer is internal to the stream and client
classes don't need to be aware of them.

- Purush

Re: Making C++ implementation same as std

Posted by Thiruvalluvan MG <th...@yahoo.com.INVALID>.
 
Thank you.
    On Tuesday, 17 December, 2019, 09:36:44 am IST, Purushotham Nayak <pu...@gmail.com> wrote:  
 
 Hi Thiru,

Thanks for pointers. I will split up the changes into two parts. First,
just add support for C++11 without breaking existing users and then in next
step will work on updating the streams. Will create a pull request once the
first part is done.

Thanks,
Purush
  

Re: Making C++ implementation same as std

Posted by Purushotham Nayak <pu...@gmail.com>.
Hi Thiru,

Thanks for pointers. I will split up the changes into two parts. First,
just add support for C++11 without breaking existing users and then in next
step will work on updating the streams. Will create a pull request once the
first part is done.

Thanks,
Purush

Re: Making C++ implementation same as std

Posted by Thiruvalluvan MG <th...@yahoo.com.INVALID>.
 HiĀ  Purush,
Thank you for taking this up. I think we can do this provided, it does not break code written against current Avro. In particular we need to to ensure that it is "source compatible" (meaning existing client code should continue to work) and "compiler version compatible" (meaning it should compile against C++11 or later).
Please go ahead and submit your pull request, we'll review and come back.
Thank you,
Thiru


    On Friday, 13 December, 2019, 06:39:48 am IST, Purushotham Nayak <pu...@gmail.com> wrote:  
 
 Hi Everyone,

There are a few changes I wanted to make to the C++ implementation and make
compatible with std (and asio) streams as well as update it to use
C++11/14. I wanted to see what other thought. I would be happy to make the
change. I already have an implementation along these lines.

Currently, we use the output stream like this:

std::auto_ptr<avro::OutputStream> out =
avro::fileOutputStream("complex.dat", 4096);
avro::EncoderPtr e = avro::binaryEncoder();
e->init(*out);
c::cpx c1;
c1.re = 1.0;
c1.im = 2.13;
avro::encode(*e, c1);

Instead we should able to do like this:

avro::ostream os("complex.dat", ios_base::binary); // avro binary stream
c::cpx c1;
c1.re = 1.0;
c1.im = 2.13;
os << c1;

In other words, it should work similar to std stream. The use of
ios_base::binary or not decides whether this is a binary / json stream. The
implementation of the encoder/buffer is internal to the stream and client
classes don't need to be aware of them.

- Purush
  

Re: Making C++ implementation same as std

Posted by Svante Karlsson <sv...@csi.se>.
Awesome.

On Fri, Dec 13, 2019, 02:09 Purushotham Nayak <pu...@gmail.com>
wrote:

> Hi Everyone,
>
> There are a few changes I wanted to make to the C++ implementation and make
> compatible with std (and asio) streams as well as update it to use
> C++11/14. I wanted to see what other thought. I would be happy to make the
> change. I already have an implementation along these lines.
>
> Currently, we use the output stream like this:
>
> std::auto_ptr<avro::OutputStream> out =
> avro::fileOutputStream("complex.dat", 4096);
> avro::EncoderPtr e = avro::binaryEncoder();
> e->init(*out);
> c::cpx c1;
> c1.re = 1.0;
> c1.im = 2.13;
> avro::encode(*e, c1);
>
> Instead we should able to do like this:
>
> avro::ostream os("complex.dat", ios_base::binary); // avro binary stream
> c::cpx c1;
> c1.re = 1.0;
> c1.im = 2.13;
> os << c1;
>
> In other words, it should work similar to std stream. The use of
> ios_base::binary or not decides whether this is a binary / json stream. The
> implementation of the encoder/buffer is internal to the stream and client
> classes don't need to be aware of them.
>
> - Purush
>