c++ - 原始消息上的 MessageDifferencer 是否处理映射?
问题描述
我必须检查我的程序(C++)的两个 protobuf 消息之间的差异。我正在为此尝试MessageDifferencer::Compare和MessageDifferencer::Equals。
我map
在 proto 消息中有一个字段,据我们所知,它不能保证被订购。所以,我想知道MessageDifferencer
对此有何看法?有没有人出局Compare
或Equals
职能部门有东西可以处理这种情况?
我的意思是,如果地图没有排序,我们如何确定第一条消息中的所有元素都与第二条消息中的正确元素进行了比较?
我的信息是这样的:
message foo
{
// some-fields
map<string, int64> bar = 2;
// more-fields
}
我是 C++ 和 protobuf 的新手,所以任何正确方向的想法都会有所帮助。
更新:
即使我比较相同的消息,它也显示不匹配,我可以在差异报告中看到这是因为相同的字段没有相互匹配。
从 protobuf文档:
Wire format ordering and map iteration ordering of map values is undefined, so you cannot rely on your map items being in a particular order.
解决方案
推荐阅读
- google-apps-script - 使用 Google Apps Script Advanced Drive API - Drive.Files.get 获取文件内容 - 或导出
- c# - SSIS 读取一个 System.Object 变量并在脚本组件中写入它......如何?
- azure-devops - 如何在构建中使用用户能力作为变量?
- sql - 每天按 SKU 运行总和
- jquery - 如何根据另一个下拉 jquery 获取要更新的下拉值
- angular - 如何在路由参数更改时测试 ngrx 商店操作调度?
- c++ - 为什么这是段错误?
- java - 用java中的空格替换json字符串中的特殊字符(不可打印字符)
- java - 自动回复电子邮件 Java J2EE (javamail)
- typescript - 使用nodejs ECMAScript模块时如何配置打字稿