> As the example on the avro c website shows, > > Create datum for record > avro_datum_t person = avro_record(person_schema); > > > Create Datun for a field > avro_datum_t id_datum = avro_int64(++id); > > Set the field value in the record > avro_record_set(person, "ID", id_datum) > > With the above API being deprecated, >
> How do I set avro_value_t in a record ? > > I tried searching for counterpart ofavro_value_get_by_name > but could not find it With the old datum API, you had to create a new datum instance for the field's value, and then assign that field datum to the record datum (just like you did). With the value API, the record value is responsible for creating and managing its fields. So you use avro_value_get_by_name to retrieve the field, regardless of whether you're going to read from that field or write into it. So the value equivalent of your example is: avro_schema_t person_schema; avro_value_iface_t *person_iface; avro_value_t person; avro_value_t field; // Create value for record person_iface = avro_generic_class_from_schema(person_schema); avro_generic_value_new(person_iface, &person); // Set field value in record avro_value_get_by_name(&person, "ID", &field, NULL); avro_value_set_long(&field, ++id); cheers –doug
signature.asc
Description: OpenPGP digital signature