avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Lim <michael...@gmail.com>
Subject Re: Avro C API: Union has no selected branch
Date Tue, 30 Sep 2014 16:14:15 GMT
Thanks Mika for your reply.

I tried avro_value_get_current_branch(&field, &branch), but now the error
is thrown here for me. I am using Avro 1.7.7.


On Tue, Sep 30, 2014 at 7:02 AM, Mika Ristimaki <mika.ristimaki@gmail.com>
wrote:

> Hi,
>
> Not sure if this works but you can try:
>
> On 30 Sep 2014, at 07:39, Michael Lim <michael626@gmail.com> wrote:
> > avro_value_t node;
> > avro_value_t field;
> > avro_value_t branch;
> > avro_generic_value_new(valueIface, &node); //valueIface was instantiated
> with the schema below
> > avro_value_get_by_name(&node, "left", &field, NULL);
> > avro_value_t leftNode = some other node that I'd like to copy into the
> "left" field of the "node" variable
> >
>
> avro_value_get_current_branch(&field, &branch);
> avro_value_copy(&branch, &leftNode);
>
> Instead of the stuff below. I know it looks bit strange but at least it
> works for me.
>
> -Mika
>
> > avro_value_set_branch(&field, 0, &branch); //no error here
> > avro_value_copy(&branch, &leftNode); //"Union has no selected branch"
> error is thrown here
> >
> > But it works if I do:
> > avro_value_set_branch(&field, 1, &branch);
> > avro_value_set_null(&branch);
> >
> > The only other example I could find is this. Thanks in advance for
> looking.
>
>

Mime
View raw message