I am trying to read an avro file using the avrocpp library, and I am required to use an external read function which reads the file into a buffer (the file itself is unavailable to me). When I have the file locally, I create a DataFileReader using the constructor with the file name parameter, like this:
avro::DataFileReader<avro::GenericDatum> reader("MyAvroFile.avro");
and it works great, but when i only have the buffer, I have to pass an InputStreamPtr to the constructor, and the only way to create that with the data from my buffer is via the avro::memoryInputStream function, like this:
avro::DataFileReader<avro::GenericDatum> reader(avro::memoryInputStream(buffer, fileSize));
This is where I get the following error
Exception thrown at 0x0FD5F6E0 (ucrtbased.dll) in AvroTestReader.exe: 0xC0000005: Access violation reading location 0x00000000.
And when I try debugging, i notice it happens in the DataFileReader constructor, here:
DataFileReader(std::unique_ptr<InputStream> inputStream) :
base_(new DataFileReaderBase(std::move(inputStream))) {
base_->init();
}
and that the inputStream pointer I passed to it (which should have been created in the avro::memoryInputStream(buffer,filesize) call) is empty. The buffer is properly created so there is no problem there, and I don't have the slightest idea what the problem could be. Also, because InputStreamPtr is a unique_ptr by definition, I don't understand how to correctly pass it to a constructor which requires a parameter passed by value rather than by reference (when i tried initializing it independently, and then passing it to the DataFileReader constructor, I got an error because unique_ptr cannot be copied). Any help on this would be much appreciated!
User contributions licensed under CC BY-SA 3.0