Hi Avro users,

I'm having trouble with the avro_value_set_branch function. Hoping anyone
can chime in here.

Schema for a node in a binary tree:
 {
   "type": "record",
   "name": "node",
   "fields": [
                 {"name": "featureIndex", "type": "int"},
                 {"name": "split", "type": "double"},
                 {"name": "value", "type": "double"},
                 {"name": "left", "type": ["node", "null"]},
                 {"name": "right", "type": ["node", "null"]}
   ]
}

Here's the code snippet leading up to the error.

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_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
<http://mail-archives.apache.org/mod_mbox/avro-user/201209.mbox/%3CCAB75mSU7ALxrB50TUjhqf0krJqk7=ugrtfxk8zo584tx9wk...@mail.gmail.com%3E>.
Thanks
in advance for looking.

Reply via email to