我正在尝试使用C实现序列化数据。 (简化的)模式是这样的:
[{
"type" : "record",
"name" : "Global",
"fields" : [
{
"name" : "source",
"type" : "string"
},
{
"name" : "timestamp",
"type" : "long"
}]
},
{
"type" : "record",
"name" : "seb_sup",
"fields" : [
{
"name" : "global",
"type" : "Global"
}
]
}]
我找不到使用C API的正确方法。 我已经尝试过这样的事情:
avro_schema_t sch_seb_sup = avro_schema_get_subschema (sch_schema, "seb_sup");
check_p (iface = avro_generic_class_from_schema (sch_seb_sup));
avro_value_t seb_sup;
check_i (avro_generic_value_new (iface, &seb_sup));
// populate the global part
avro_value_t global;
check_i (avro_value_get_by_name (&seb_sup, "global", &global, NULL));
check_i (avro_value_get_by_name (&global, "source", &field, NULL));
check_i (avro_value_set_string (&field, "seb"));
check_i (avro_value_get_by_name (&global, "timestamp", &field, NULL));
check_i (avro_value_set_long (&field, 12345678));
check_i (avro_file_writer_append_value (db, &seb_sup));
,但是执行显示错误: 错误:从未为Global创建值实现
我应该如何使用C API?
关于, Arnaud