You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Joseph Winston <jo...@gmail.com> on 2014/02/10 02:18:15 UTC

C++ sample in 1.7.6 fails with EOF reached using a record containing a filed with a string

If I have a schema that looks like this:

{"namespace": "Dummy",
"type": "record",
"name": "String",
"fields": [
    {"name": "name", 
    "type": "string",
    "default": "NONE",
    "doc": "The Name"
    }
]
}

With a program to set and retrieve the value of the name based on generated.cc found in the C++ documentation:

#include <cstdlib>              // for EXIT_SUCCESS
#include <stdexcept>

#include <Dummy.hpp>

#include <avro/Encoder.hh>
#include <avro/Decoder.hh>

int
main(int argc,
    char **argv)
{
  std::auto_ptr<avro::OutputStream> out = avro::memoryOutputStream();
  avro::EncoderPtr e = avro::binaryEncoder();
  e->init(*out);

  Mine::String anInput;
  anInput.name = "This is a name";

  std::auto_ptr<avro::InputStream> in = avro::memoryInputStream(*out);
  avro::DecoderPtr d = avro::binaryDecoder();
  d->init(*in);

  Mine::String anOutput;

  try
  {
     avro::decode(*d, anOutput);
  }
  catch (std::exception& e) 
  {
     std::cerr << e.what() 
               << std::endl;

     exit (EXIT_FAILURE);
  }

  return EXIT_SUCCESS;
}

On O X 10.9.1 using clang version 3.3 (tags/RELEASE_33/final), I receive the following exception when the program is run:

EOF reached

Is this a known issue with the C++ bindings in avro 1.7.6?