【问题标题】:protocol buffer lite versus regular protocol buffer协议缓冲区精简版与常规协议缓冲区
【发布时间】:2011-09-18 08:17:00
【问题描述】:

我一直在研究 c++ 序列化框架将占用更少的空间和良好的性能。我找到了这个帖子

c++ network serialization

这基本上建议使用协议缓冲区的精简版。从this page不清楚lite版的具体功能是什么

我的问题是;坚持使用 protocol buffers lite 会丢失哪些功能?

【问题讨论】:

    标签: c++ serialization protocol-buffers


    【解决方案1】:

    “lite”版本无法与iostreamFileDescriptor”进行序列化,也无法使用Reflection功能(尽管it does use refection),和...一些其他功能。

    我的建议是只使用精简版,直到遇到需要完整版的功能。从一个切换到另一个非常容易。

    如果您需要查看精简版缺少的列表,我建议您浏览<google/protobuf/message.h>。基本上,该包含文件中的所有内容都是完整版独有的。 (<google/protobuf/message_lite.h> 是完整版的#included。) 这是一个链接: https://github.com/google/protobuf/blob/master/src/google/protobuf/message.h

    【讨论】:

    • 如果您使用精简版,请不要忘记将option optimize_for = LITE_RUNTIME; 添加到您的 .proto 文件中。
    • 阅读 cmets 是一场情绪过山车。
    • 已编辑以反映SerializeToOstream()class MessageLite 中的存在(目前)