I am trying to use the c++ generic interface to update the following record:


{

    "type": "record",

    "namespace": "com.abc.v1",

    "name": “def",

    "fields": [

        {

            "name": "id",

            "type": [

                "null",

                "bytes"

            ]

        }

    ]

}


The following is the way that I try to do the update is through the 
GenericDatum. The code compile but when throw an exception of:


uncaught exception of type N4avro9ExceptionE

- Not that many names


std::vector<uint8_t> postdata;

uint8_t idarray[] = { 35, 36, 37, 38 };

std::copy( idarray, idarray + 3, std::back_inserter( postdata ));



avro::GenericDatum dat( schema ); // dat was filled with null by default

dat.setFieldAt(0, postdata); // trying to replace the null with bytes


std::auto_ptr<avro::OutputStream> out = avro::fileOutputStream( "/tmp/fout" );

avro::EncoderPtr en = avro::jsonEncoder( schema );

en->init ( *out );

avro::encode ( *en, dat );



Reply via email to