You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Nicolas Ranc <rn...@gmail.com> on 2016/08/25 08:02:44 UTC

AVRO C++ ARRAY DECODING

Hello,
I want to deserialize data using apache avro c++. I want to decode my avro
file (with schema and data). avrofile = test.bin , there is just a record
with an array inside.

avro::DataFileReaderBase decode("test.bin");
while(decode.hasMore()){ //1
        if(test.getValue().isNull()){
            std::cout<<"Null "<<std::endl;
        }else if (test.getValue().isString()){ //The data is an array but
it goes in this case
              std::cout<<"heyyyy";
for (size_t m = decode.decoder().arrayStart(); m != 0; m =
decode.decoder().arrayNext()) {
std::cout<<decode.decoder().decodeString()<<" "; //Doesnt work
                  //decode.decoder().???; I want to access to array's data

                                }
        }else if(test.getValue().isBool()){
            std::cout<<"Bool: "<<decode.decoder().decodeBool()<<std::endl;
        }else if(test.getValue().isDouble()){
            std::cout<<"Double:
"<<decode.decoder().decodeDouble()<<std::endl;
        }else if(test.getValue().isArray()){
                                                        //NEVER HERE
        }else{std::cout<<"pb";}
    }



OUTPUT :
terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::resize
heyyyyheyyyy Aborted (core dumped)

Can someone help me please? thanks
I don't find a lot of information about decode.decoder().arrayStart() /
arrayNext() in the internet.