[ https://issues.apache.org/jira/browse/AVRO-4160?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated AVRO-4160: --------------------------------- Labels: pull-request-available (was: ) > Replace std::any with std::optional and std::variant in generated structs. > -------------------------------------------------------------------------- > > Key: AVRO-4160 > URL: https://issues.apache.org/jira/browse/AVRO-4160 > Project: Apache Avro > Issue Type: Improvement > Components: c++ > Reporter: John Dickson > Priority: Minor > Labels: pull-request-available > Time Spent: 10m > Remaining Estimate: 0h > > C++'s std::any is very powerful, and expensive to use. Since all the types > are known, avrogencpp generated structures can leverage std::variant for > union types instead. The interface of std::variant maps to the avro union > interface, providing a built in union discriminator which removes the need > for avro union structures to store a second member variable. More > importantly, this relieves a lot of pressure on the memory allocator for > deeply nested schemas when unions are heavily used. > In addition, when a union contains two types, and one of those types is null, > std::optional can be used for even lighter weight union implementation. > This can be done with no changes to the API. The emitted structures can even > be used with previous versions of the avro library. > Real world testing in our case, this single change reduced transaction times > by 50% -- This message was sent by Atlassian Jira (v8.20.10#820010)