为什么AvroCoder不具有确定性? [英] Why isn't the AvroCoder deterministic?

查看:87
本文介绍了为什么AvroCoder不具有确定性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AvroCoder.isDeterministic 返回false.

为什么AvroCoder不具有确定性? Avro记录是否总是编码为相同的字节流?

Why isn't the AvroCoder deterministic? Wouldn't Avro records always be encoded into the same byte stream?

由于Avro编码器不确定,因此不能将Avro记录用作按操作分组的键.将Avro记录转换为密钥的最佳方法是什么?我们应该只使用Avro记录的json表示形式吗?

Since the Avro Coder isn't deterministic an Avro record can't be used as a Key for a group by operation. What's the best way to turn an Avro record into a key? Should we just use the json representation of the Avro record?

推荐答案

基于 Avro规范,看起来只有数组和映射具有不确定的二进制编码.

Based on the Avro specification it looks like only Arrays and Maps have non deterministic binary encoding.

由于两个原因,地图看起来不确定地编码

Maps look like they are non deterministically encoded for two reasons

  • 未指定元素的顺序
  • 可以通过指定块中的元素数或字节数,以两种不同的方式对块进行编码.

数组看起来像是不确定地编码的,因为

Arrays look like they are non deterministically encoded because

  • 可以通过指定块中的元素数或字节数,以两种不同的方式对块进行编码.

因此,对于没有数组或映射的任何模式,我认为二进制编码应该是确定性的.因此,我认为我们可以通过子类化

So for any schema without an array or a map, I think the binary encoding should be deterministic. So I think we could create a deterministic encoder just by subclassing AvroCoder and overriding AvroCoder.isDeterministic to return true.

AvroDeterministicCoder/a>是我首次尝试创建这样的编码器.

AvroDeterministicCoder is my first attempt at creating such a coder.

这篇关于为什么AvroCoder不具有确定性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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