avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ellisdp <david.el...@diegesis.co.uk>
Subject Getting access to binary encoded data (C++)
Date Fri, 20 Dec 2013 15:59:47 GMT
Having come from the Java world where I can do:

/ByteArrayOutputStream out = new ByteArrayOutputStream();
BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(out, null);
SpecificDatumWriter<lswrapper> writer = new SpecificDatumWriter<>(xx.class);

writer.write(content, encoder);

return out.toByteArray();/

I am now trying to do the equivalent in C++. The documentation shows:

/std::auto_ptr<avro::OutputStream> out = avro::memoryOutputStream();
avro::EncoderPtr e = avro::binaryEncoder();
avro::encode(*e, <xx>);/

and I can do this but I don't know how to then get a copy of the encoded
bytes. I would like to get this in a variable of type:


so that I can pass this back for use elsewhere in my program, but
avro::OutputStream does not seem to provide any methods to do this.

I have tried instead doing:

/ostringstream os;
auto_ptr<avro::OutputStream> oStream = avro::ostreamOutputStream(os);
and then using /os.str()/ to access the data, but I am not sure if this is
right and it does not seem to work.

Seems like it should be simple, but I can't figure it out!

View this message in context: http://apache-avro.679487.n3.nabble.com/Getting-access-to-binary-encoded-data-C-tp4028890.html
Sent from the Avro - Users mailing list archive at Nabble.com.

View raw message