avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joey Echeverria <j...@cloudera.com>
Subject Re: Avro serialization using php
Date Fri, 11 Jul 2014 00:53:57 GMT
I've not used the PHP bindings, so this may not be the full procedure.

You should be able to create an AvroIODatumWriter[1] to write to a
string. In order to do that, you need to first create an
AvroStringIO[2] and wrap that in a AvroIOBinaryEncoder[3]. It should
look something like this:

$io = new AvroStringIO();
$encoder = new AvroIOBinaryEncoder($io);
$writer = new AvroIODataumWriter($schema);
$writer->write($datum, $encoder);
$io->string(); // gets the serialized data as a string which in PHP is
an array of bytes


[1] https://github.com/apache/avro/blob/trunk/lang/php/lib/avro/datum.php#L73
[2] https://github.com/apache/avro/blob/trunk/lang/php/lib/avro/io.php#L146
[3] https://github.com/apache/avro/blob/trunk/lang/php/lib/avro/datum.php#L231

On Thu, Jul 10, 2014 at 6:28 PM, Vadim Keylis <vkeylis2009@gmail.com> wrote:
> How do I just serialize single message using php? It appears php uses
> Container Files serialization approach and for my project I need to
> serialize single message without attaching schema as header.
> Thanks so much for your help

Joey Echeverria

View raw message