Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 阿帕奇Avro“;“异构阵列”;_C++_Arrays_Avro_Heterogeneous - Fatal编程技术网

C++ 阿帕奇Avro“;“异构阵列”;

C++ 阿帕奇Avro“;“异构阵列”;,c++,arrays,avro,heterogeneous,C++,Arrays,Avro,Heterogeneous,是否有人可以建议如何在Avro中使用异构阵列(如果可能)。我想不出是什么把戏 我的模式是: { “类型”:“数组”、“项”:[“空”、“字符串”] } 我没有使用生成的标题,只是尝试在代码中完成这一切: avro::ValidSchema schema; avro::compileJsonSchema(ifs, schema); avro::EncoderPtr e = avro::binaryEncoder(); avro::DecoderPtr d = avro::binaryDecod

是否有人可以建议如何在Avro中使用异构阵列(如果可能)。我想不出是什么把戏

我的模式是:

{
“类型”:“数组”、“项”:[“空”、“字符串”]
}
我没有使用生成的标题,只是尝试在代码中完成这一切:

avro::ValidSchema schema;
avro::compileJsonSchema(ifs, schema);

avro::EncoderPtr e = avro::binaryEncoder();
avro::DecoderPtr d = avro::binaryDecoder();

avro::GenericDatum datum(schema);
avro::GenericArray& array = datum.value<avro::GenericArray>();

array.value().push_back(avro::GenericDatum(std::string("lala")));

std::auto_ptr<avro::OutputStream> out = avro::memoryOutputStream();
e->init(*out);
avro::encode(*e, datum);

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

avro::GenericDatum ddatum(schema);
avro::decode(*d, ddatum);
我假设我正在将
genericdatam
推送到编码流中,但应该以某种方式指定这是一个并集的值。。我不知道该怎么做

编辑:

我能够通过直接编码模式的元素来实现我想要的:

std::auto_ptr out=avro::memoryOutputStream();
e->init(*out);
e->arrayStart();
e->setItemCount(COLS);
char-buf[10];
对于(int j=0;j编码索引(1);
e->encodeString(std::string(buf));
}
e->arrayEnd();
e->flush();
然而,对于我来说,是否有办法通过
genericdatam
实现这一点仍然是个谜

Exception: vector::_M_range_check: __n (which is 4) >= this->size() (which is 2)