Python avro嵌套方案多个子记录
关于我的avro计划,我有一个问题。这是我为测试而编写的代码:Python avro嵌套方案多个子记录,python,python-3.x,avro,Python,Python 3.x,Avro,关于我的avro计划,我有一个问题。这是我为测试而编写的代码: import avro.schema from avro.datafile import DataFileReader, DataFileWriter from avro.io import DatumReader, DatumWriter schema = avro.schema.Parse(open("user.avsc").read()) writer = DataFileWriter(open("users.avro",
import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter
schema = avro.schema.Parse(open("user.avsc").read())
writer = DataFileWriter(open("users.avro", "wb"), DatumWriter(), schema)
writer.append({"count" : 5, "cvList" : {"id" : 5}})
writer.close()
模式:
{
"name" : "cv",
"type" : "record",
"fields" : [
{"name" : "count", "type" : "int"},
{"name" : "cvList",
"type": {
"name" : "cvData",
"type" : "record",
"fields" : [
{"name" : "id", "type" : "int"}
]
}
}
]
}
我想做以下工作:
append count(稍后将显示cvList的数量),然后我希望能够在cvList中添加可变数量的id。我可以添加一个计数和一个id,但不能附加多个id。我想我得重写计划,但我不知道该怎么做
葛吕埃
马吕斯你能解决这个问题吗马吕斯?如果是,你能告诉我你是如何解决的吗?已经有一段时间了,但是我解决了这个问题,但是我现在没有时间,但是也许这对你有帮助:。如果没有,我会尝试告诉你如何解决它。