You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Thiruvalluvan M. G. (Jira)" <ji...@apache.org> on 2021/09/02 02:31:00 UTC
[jira] [Commented] (AVRO-3194) [C++] Parsing avro file using
`GenericDatum` results in segmentation fault
[ https://issues.apache.org/jira/browse/AVRO-3194?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17408485#comment-17408485 ]
Thiruvalluvan M. G. commented on AVRO-3194:
-------------------------------------------
[~OscarTHZhang] Is it possible to attach the offending schema to this ticket? Thank you
> [C++] Parsing avro file using `GenericDatum` results in segmentation fault
> --------------------------------------------------------------------------
>
> Key: AVRO-3194
> URL: https://issues.apache.org/jira/browse/AVRO-3194
> Project: Apache Avro
> Issue Type: Bug
> Components: c++
> Environment: Ubuntu on AWS EC2
> Reporter: Oscar Zhang
> Priority: Major
>
> Hello,
> I wonder what's the correct example of parsing an avro input stream into a vector of `GenericRecord`?
> I am trying to parse .avro file using `GenericDatum` to store them in a vector of `GenericRecord`, but I got a segmentation fault (signal 11) when I am trying to call `datum.value()`. Here is the sample code that I am writing:
> {code:java}
> std::unique_ptr<avro::InputStream> avroInputStream = avro::istreamInputStream(retrievedFile); // `retrievedFile` is a basic_iostream from AWS S3
> // get the schema file
> std::stringstream schemaInput(schemaName);
> avro::ValidSchema validSchema;
> avro::compileJsonSchema(schemaInput, validSchema);
> // read the data input stream with the given valid schema
> avro::DataFileReader<avro::GenericDatum> fileReader(move(avroInputStream));
> avro::GenericDatum datum(fileReader.dataSchema());
> std::vector<avro::GenericRecord> recordArray;
> while (fileReader.read(datum)) {
> if (datum.type() == avro::AVRO_RECORD) {
> std::cout << "[Check 1]" << std::endl;
> const avro::GenericRecord record = datum.value<avro::GenericRecord>(); // result in segmentation fault
> std::cout << "[Check 2]" << std::endl;
> recordArray.push_back(record);
> }
> }
> // processing the recordArray further
> ...{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)