Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> [avro-c] reading NULL-able unions


Copy link to this message
-
[avro-c] reading NULL-able unions
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
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB