Hi guys,
I am facing problem in encoding the nullable fields.
Hi Doug,
I thought i was using it correctly, but running into issues of using the
union with nullable fields.
Doing something like:
Schema: This is just snippet, the whole schema is not posted.
{
"name": "protocol",
"type": [
"string",
"null"
]
},
{
"name": "port_number",
"type": [
"long",
"null"
],
"doc": "Port"
},
}
acos_avro_check_i(avro_value_get_by_name(&writer_value, "port_number",
&field, NULL));
acos_avro_check_i(avro_value_set_branch(&field, 1, &branch));
acos_avro_check_i(avro_value_set_null(&branch));
acos_avro_check_i(avro_value_set_int(&branch, 80));
/*protocol*/
acos_avro_check_i(avro_value_get_by_name(&writer_value, "protocol",
&field, NULL));
acos_avro_check_i(avro_value_set_branch(&field, 1, &branch));
acos_avro_check_i(avro_value_set_null(&branch));
acos_avro_check_i(avro_value_set_string(&branch, "tcp"));
Posting it.
But getting error when i try to set the value for say set_int or set_string.
I can't seem to understand why it is failing.
Is this correct way to encode a union field or are there some better
examples i can look at ?
--
View this message in context:
http://apache-avro.679487.n3.nabble.com/Using-optional-fields-nullable-unions-with-the-C-API-tp3525392p4037669.html
Sent from the Avro - Users mailing list archive at Nabble.com.