avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam McVeety <sam.mcve...@gmail.com>
Subject CPP serialization of generic record
Date Wed, 10 Aug 2016 01:56:03 GMT
Hello, I'm seeking advice on how to serialize a generic record with a
schema that is determined at runtime.  I know that the schema has no nested
records, so I'm wondering if the following is sufficient, or if there are
other considerations I should be aware of:

namespace avro {
  template<>
  struct codec_traits<avro::GenericRecord> {
    static void encode(Encoder& e, const avro::GenericRecord& c) {
      for (int i = 0; i < c.fieldCount(); ++i) {
        avro::encode(e, c.fieldAt(i));
      }
    }

    static void decode(Decoder& d, avro::GenericRecord& c) { /* not needed
*/}
  };
}

Thanks,
Sam

Mime
View raw message