如何更改Google的protobuf中的缓冲区限制? [英] How to change the buffer limit in Google's protobuf?

查看:4930
本文介绍了如何更改Google的protobuf中的缓冲区限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试解析大型邮件时,我收到此警告和错误。我知道超过64MB这是默认限制。我现在使用message.ParseFromIstream。有没有人知道访问CodedInputStream对象来调用SetTotalBytesLimit函数?或任何其他方式来解决这个问题?

I'm getting this warning and an error afterwards when I try to parse a large message. I know than 64MB which is the default limit. I am using message.ParseFromIstream now. Does any one know to get access to CodedInputStream object to call the SetTotalBytesLimit function? or any other way to solve this problem?


读取危险的大型协议消息。如果消息变为
大于67108864字节,解析将暂停为安全
原因。要增加限制(或禁用这些警告),请参阅
中的
CodedInputStream :: SetTotalBytesLimit()google / protobuf / io / coded_stream.h。

Reading dangerously large protocol message. If the message turns out to be larger than 67108864 bytes, parsing will be halted for security reasons. To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.


推荐答案

正确的修复:你应该尽量限制protobuf消息的大小。请参阅:
https://developers.google.com/protocol- buffers / docs / techniques#streaming

The correct fix: You should try to limit the sizes of your protobuf messages. Please see: https://developers.google.com/protocol-buffers/docs/techniques#streaming

快速和脏(读不推荐)方法:
在protobuf的coded_stream.h文件库源,更改 kDefaultTotalBytesLimit kDefaultTotalBytesWarningThreshold 的值,重新编译并重新安装。

The quick and dirty (read not recommended) approach: In the file coded_stream.h of the protobuf library source, change the values of kDefaultTotalBytesLimit and kDefaultTotalBytesWarningThreshold, recompile, and reinstall.

这篇关于如何更改Google的protobuf中的缓冲区限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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