You need to call flush(). Send common usecaee below

auto bin_os = avro::memoryOutputStream();
      avro::EncoderPtr bin_encoder = avro::binaryEncoder();
      bin_encoder->init(*bin_os.get());
      avro::encode(*bin_encoder, src);
      bin_encoder->flush(); /* push back unused characters to the
output stream again, otherwise content_length will be a multiple of
4096 */


n Sat, Oct 27, 2018, 20:34 Olivier Delbeke <[email protected]>
wrote:

> Hi all,
>
> Just started with AVRO (in C++) and a bit stuck (so this will be an easy
> question).
> All examples show how to encode data and decode it right after you did
> that, so you can immediately connect the OutputStream to the InputStream,
> completely ignoring the size of the encoded data. However, what I'd like to
> do is to send the data to Kafka, so I need to know how many bytes I need to
> read from the stream. After encoding, the byteCount() of the OutputStream
> always returns 4096 which looks huge for 3 doubles and a short string. When
> I read back those 4096 bytes of data, I can indeed see that only the first
> 40 bytes are non-zeros. I cannot find any method in the Encoder or in the
> OutputStream that does return the length of the encoded data. Am I
> overlooking something ?
>
> Thanks,
>
> Olivier
>

Reply via email to