avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JJ <ja...@php.net>
Subject [avro-c] reading NULL-able unions
Date Thu, 20 Sep 2012 21:09:03 GMT
Hey all - my question is closely related to
http://grokbase.com/p/avro/user/11bpkbyxk5/using-optional-fields-nullable-unions-with-the-c-api
... which focuses writing nullable unions.

I'd like to figure how to properly read nullable unions. I tried it on
my own by looking through the avropipe.c source (process_union)
however I get the following error when I try to call
avro_value_get_current_branch:

"Union has no selected branch"

I've enabled DEBUG_BRANCHES and here is the output around the
avro_value_set_branch call:

Branch 0, size 4
Branch 1, size 48
MAX BRANCH SIZE: 48
Selecting branch 0 (was -1)
Initializing branch 0
Selecting branch 0 (was 0)
Finalizing branch 0
Branch 0, size 4
Branch 1, size 48
MAX BRANCH SIZE: 48

The schema is available @
https://api.x.com/ocl/com.x.ecosystemmanagement.v1/PingPong/Ping/1.0.6

The relevant set code is (results in "Union has no selected branch"
even if I use the 2nd branch as a string):

avro_value_set_branch(&field, 0, &branch);
avro_value_set_null(&branch);

Am I missing something here? The discriminant always seems to be -1 as well.

- JJ

PS - there is a small bug with the #include <stdio.h> header missing
when compiled w/DEBUG_BRANCHES in src/generic.c

Mime
View raw message