协议缓冲区序列化输出是否完全确定? [英] Is protocol buffer serialization output fully deterministic?

查看:55
本文介绍了协议缓冲区序列化输出是否完全确定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定协议缓冲区架构和一些数据,协议缓冲区序列化是否跨库和语言具有确定性?

Given a protocol buffers schema and some data, is the protocol buffers serialization deterministic across libraries and languages?

基本上,无论使用什么库,我是否可以保证相同的数据总是以相同的方式(直到字节)序列化?

Basically, am I guaranteed that the same data will always serialize in the same way (down to the byte) regardless of the library used?

推荐答案

一般来说,相同的数据会以完全相同的方式进行序列化.

In general, the same data will serialize in exactly the same way.

然而,protobuf 规范并不能保证这一点.例如,以下编码差异是允许的,并且必须在所有符合标准的库中解码为相同的结果:

However, this is not guaranteed by the protobuf specifications. For example, the following differences in encoding are allowable and must decode to the same result in all conforming libraries:

  • 以与标签编号顺序不同的顺序对字段进行编码.
  • 将打包字段编码为未打包.
  • 将整数编码为比所需更长的 varint 字节序列.
  • 多次编码相同(非重复)字段.
  • 可能是其他人.

这篇关于协议缓冲区序列化输出是否完全确定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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