avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charlie Quillard (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AVRO-1674) Optional field does not work in avro-cpp
Date Fri, 29 May 2015 15:23:17 GMT
Charlie Quillard created AVRO-1674:

             Summary: Optional field does not work in avro-cpp
                 Key: AVRO-1674
                 URL: https://issues.apache.org/jira/browse/AVRO-1674
             Project: Avro
          Issue Type: Bug
            Reporter: Charlie Quillard

I have to implement an optional field in my avro schema and when i test this one with avro-py
that works and that does not works with avro-cpp.

That is my schema (cpx.json) :
  "type" : "record",
  "name" : "example",
  "fields" : [
      "name": "city",
      "type": ["null", "string"],

That is my cpp code when i test without fill my field:
typedef std::pair<avro::ValidSchema, avro::GenericDatum> Pair;

int main(int ac, char **av)

    std::ifstream ifs("cpx.json");
    avro::ValidSchema schema;
    avro::compileJsonSchema(ifs, schema);

    Pair p(schema, avro::GenericDatum());

    avro::GenericDatum &Data = p.second;
    Data = avro::GenericDatum(schema);
    avro::GenericRecord &sReord = Data.value<avro::GenericRecord>();
    avro::DataFileWriter<Pair> dataFileWriter("test.bin", schema);

This is my error when i transform my binary to json with avo-tools :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
	at org.apache.avro.io.parsing.Symbol$Alternative.getSymbol(Symbol.java:402)
	at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:290)
	at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
	at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267)
	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:155)
	at org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:193)
	at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:183)
	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:151)
	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:142)
	at org.apache.avro.file.DataFileStream.next(DataFileStream.java:233)
	at org.apache.avro.file.DataFileStream.next(DataFileStream.java:220)
	at org.apache.avro.tool.DataFileReadTool.run(DataFileReadTool.java:77)
	at org.apache.avro.tool.Main.run(Main.java:84)
	at org.apache.avro.tool.Main.main(Main.java:73)

This message was sent by Atlassian JIRA

View raw message