[
https://issues.apache.org/jira/browse/AVRO-3992?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gerrit Birkeland updated AVRO-3992:
-----------------------------------
Description:
I have an Avro schema resembling the following:
{code:java}
{
"type": "record",
"name": "StackCalculator",
"fields": [
{
"name": "stack",
"type": {
"type": "array",
"items": [
"int",
{
"type": "record",
"name": "Dup",
"fields": []
},
{
"type": "record",
"name": "Add",
"fields": []
}
]
}
}
]
}
{code}
If I create one of these records with the stack:
{code:java}
uer::StackCalculator calc;
uer::StackCalculator::stack_item_t item;
item.set_int(3);
calc.stack.push_back(item);
item.set_Dup(uer::Dup());
calc.stack.push_back(item);
item.set_Add(uer::Add());
calc.stack.push_back(item);
{code}
and try to encode this
{code:java}
ValidSchema s;
ifstream ifs("jsonschemas/union_empty_record");
compileJsonSchema(ifs, s);
unique_ptr<OutputStream> os = memoryOutputStream();
EncoderPtr e = validatingEncoder(s, jsonPrettyEncoder());
e->init(*os);
avro::encode(*e, calc);
{code}
Avro throws {{{}startItem at not an item boundary{}}}. If the records without
fields are given a dummy field, this works.
Fix available at [https://github.com/apache/avro/pull/2927] - bot didn't pick
it up since the PR was first
was:
I have an Avro schema resembling the following:
{code}
{
"type": "record",
"name": "StackCalculator",
"fields": [
{
"name": "stack",
"type": {
"type": "array",
"items": [
"int",
{
"type": "record",
"name": "Dup",
"fields": []
},
{
"type": "record",
"name": "Add",
"fields": []
}
]
}
}
]
}
{code}
If I create one of these records with the stack:
{code}
uer::StackCalculator calc;
uer::StackCalculator::stack_item_t item;
item.set_int(3);
calc.stack.push_back(item);
item.set_Dup(uer::Dup());
calc.stack.push_back(item);
item.set_Add(uer::Add());
calc.stack.push_back(item);
{code}
and try to encode this
{code}
ValidSchema s;
ifstream ifs("jsonschemas/union_empty_record");
compileJsonSchema(ifs, s);
unique_ptr<OutputStream> os = memoryOutputStream();
EncoderPtr e = validatingEncoder(s, jsonPrettyEncoder());
e->init(*os);
avro::encode(*e, calc);
{code}
Avro throws {{startItem at not an item boundary}}. If the records without
fields are given a dummy field, this works.
> [C++] Encoding a record with 0 fields in a vector throws
> --------------------------------------------------------
>
> Key: AVRO-3992
> URL: https://issues.apache.org/jira/browse/AVRO-3992
> Project: Apache Avro
> Issue Type: Improvement
> Components: c++
> Affects Versions: 1.11.3
> Reporter: Gerrit Birkeland
> Priority: Major
>
> I have an Avro schema resembling the following:
> {code:java}
> {
> "type": "record",
> "name": "StackCalculator",
> "fields": [
> {
> "name": "stack",
> "type": {
> "type": "array",
> "items": [
> "int",
> {
> "type": "record",
> "name": "Dup",
> "fields": []
> },
> {
> "type": "record",
> "name": "Add",
> "fields": []
> }
> ]
> }
> }
> ]
> }
> {code}
> If I create one of these records with the stack:
> {code:java}
> uer::StackCalculator calc;
> uer::StackCalculator::stack_item_t item;
> item.set_int(3);
> calc.stack.push_back(item);
> item.set_Dup(uer::Dup());
> calc.stack.push_back(item);
> item.set_Add(uer::Add());
> calc.stack.push_back(item);
> {code}
> and try to encode this
> {code:java}
> ValidSchema s;
> ifstream ifs("jsonschemas/union_empty_record");
> compileJsonSchema(ifs, s);
> unique_ptr<OutputStream> os = memoryOutputStream();
> EncoderPtr e = validatingEncoder(s, jsonPrettyEncoder());
> e->init(*os);
> avro::encode(*e, calc);
> {code}
> Avro throws {{{}startItem at not an item boundary{}}}. If the records without
> fields are given a dummy field, this works.
> Fix available at [https://github.com/apache/avro/pull/2927] - bot didn't pick
> it up since the PR was first
--
This message was sent by Atlassian Jira
(v8.20.10#820010)