Thanks a lot, Svante. It does the trick !

My understanding of the the Encoder::flush() was that  it would empty the
OuputBuffer (because it says "flush() : Flushes any data in internal
buffers.") This part of the documentation may benefit from some
modification.

KR



On Sat, Oct 27, 2018 at 9:00 PM Svante Karlsson <svante.karls...@csi.se>
wrote:

> 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 <olivier.delb...@gmail.com>
> 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