将Avro反序列化为通用记录而无需模式 [英] Deserialize avro to generic record without schema

查看:73
本文介绍了将Avro反序列化为通用记录而无需模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将字节数组/缓冲区反序列化为通用记录,而不需要任何模式,除了消息中编码的内容之外?

Is it possible to deserialize a byte array/buffer to generic record without having any schema available, beside what's encoded in message?

我正在编写一个组件,该组件接受传入的编码消息,并且希望使其成为通用记录,而无需任何模式支持.

I'm writing a component that takes incoming encoded message and I want to make it a generic record without having any schema on my side.

我已经假设有可能,因为架构是此编码消息的一部分,但是我不确定,如果我未在GenericDatumReader中指定架构,我将获得NPE.

I've kind of assumed it's possible, since the schema is part of this encoded message but I'm not sure anymore, I'm getting NPE if I don't specify schema in GenericDatumReader.

推荐答案

如果您将模式嵌入标头中,则应该可以,因为与读取.avro文件(首先指定模式)相同.如果您在没有在头文件上指定架构的情况下序列化avro,除非您从诸如Schema Registry之类的中央服务中获取架构,或者事先拥有该架构,否则我认为无法对它进行反序列化

If you embed the schema in the header it should be possible, since it is the same that if you read an .avro file where the schema is specified at first. If you serialize the avro without specifying the schema on the header I don't think it is possible to deserialize it unless you get the schema from a central service like Schema Registry or you have the schema beforehand

这篇关于将Avro反序列化为通用记录而无需模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆