【发布时间】:2019-06-08 10:21:49
【问题描述】:
Microsoft Azure 在某些情况下决定以 avro 格式转储数据。从我的角度来看,有问题的数据只是 json 记录。所以,我只想从 avro 文件中返回我的 json 数据。
我正在研究如何“反序列化”avro 数据,以及此处的示例:
https://avro.apache.org/docs/1.8.1/gettingstartedjava.html
提出索赔:
Data in Avro is always stored with its corresponding schema, meaning we can always read a serialized item regardless of whether we know the schema ahead of time.
不幸的是,这些示例确实需要提前了解架构:
DatumReader<GenericRecord> datumReader = new GenericDatumReader<GenericRecord>(schema);
DataFileReader<GenericRecord> dataFileReader = new DataFileReader<GenericRecord>(file, datumReader);
我一定是遗漏了一些东西,我只想要我的数据(文本/json)格式,脱离 avro。有没有办法在不知道架构的情况下做到这一点? avro 不能从文件本身中读取它吗?
【问题讨论】: