Log Message: |
AVRO-727. This patchs several missing accessor and mutator methods for Avro
schemas and data instances.
For the most part, their definitions are straightforward. Some notes for the
more interesting cases:
- You can create the appropriate avro_datum_t instance for an
arbitrary schema with the new avro_datum_from_schema() function.
For records, this includes creating a datum instance for each of the
record's fields. Arrays and maps are initially created empty, while
a union is created with none of its branches initially selected.
This prevents the function from going into an endless loop for
recursive schemas.
- The active branch of a union can now be changed. If the desired
branch is already active, this has no result. Otherwise, a new
avro_datum_t is created for the new branch.
- Map values can now be accessed by index as well as by key. The
index of a map entry is based on the order that it was added to the
map.
- Enum values can be retrieved or set either by integer value or by
symbol name.
A couple of the new functions need access to the schema of a datum in
order to work. These functions take in the schema instance as an extra
parameter. A better solution might be to include a reference to a
schema object in each avro_datum_t instance.
|