我的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"}
]
}
}
]
}
我想做以下事情: 追加计数(稍后出现的cvLists的数量),然后我希望能够在cvList中添加可变数量的id。我可以添加一个计数和一个id,但我无法追加多个id。我想我必须重写这个计划,但我不知道如何。
Grüße
的Marius