protobuf编码原理 |
| 时间:2025-03-19 10:59:25 来源:互联网 作者: |
AI导航网,AI网站大全,AI工具大全,AI软件大全,AI工具集合,AI编程,AI绘画,AI写作,AI视频生成,AI对话聊天等更多内容请查看 https://aiaiv.cn/
知乎Protobuf 是由 Google 设计的一种高效、轻量级的信息描述格式, 起初是在 Google 内部使用, 后来被开放出来, 它具有语言中立、平台中立、高效、可扩展等特性, 它 Protobuf 的一个典型应用场景便是做通信的数据交换格式, 它在通信管道上是以纯二进制的形式进行传输, 发送端使用编码器将数据序列化为二进制, 接收端 展开1. Varints 编码通常来说, 普通的 int 数据类型, 无论其值的大小, 所占用的存储空间都是相等的, 可见, 只有最后一个字节存储了有效数值, 前 3 个字节都是 0, 若采用 Varints 编 因为其没有后续字节, 因此其最高有效位为 0, 其余的 7 位以补码形式 展开3. Protobuf 的数据组织在上面的讨论中, 我们了解了 Protobuf 所使用的 Varints 编码和 Zigzag 编码的编 Request 中包含了一个名称为 name 的字段, 客户端和服务端双方都用同一份相 在这种情形下, 服务端不修改应用程序仍能够正确地解码, 原因在于序 展开2. Zigzag 编码Varints 编码的实质在于去掉数字开头的 0, 因此可缩短数字所占的存储字节数, 在 Request 中包含类型为 int32 类型的字段, 当 a 为负数时, 其序列化之后将恒定占 对于 int32 类型的数字 -5, 其序列化之后的二进制为 展开4. 总结总结一下以上所论述的内容。1.Protobuf 是一种高效的数据描述格式, 具有平台无关、语言无关、可扩展等特 2.Protobuf 采用 Varints 编码和 Zigzag 编码来编码数据, 其中 Varints 编码的思 3.Protobuf 不是完全自描述 展开来自 Zhihu内容1. Varints 编码2. Zigzag 编码3. Protobuf 的数据组织4. 总结查看所有章节更多内容请查看https://zhuanlan.zhihu.com/p/404782892
.rcimgcol .cico { background: #f5f5f5; } .b_dark .rcimgcol .cico { background: unset; }.b_imgSet .b_hList li.square_m,.b_imgSet .b_hList li.tall_m{width:75px}.b_imgSet .b_hList li.tall_mlb{width:113px}.b_imgSet .b_hList li.tall_mln{width:96px}.b_imgSet .b_hList li.wide_m{width:128px}.b_imgSet.b_Card .b_hList li{padding-left:1px;padding-right:9px}.b_imgSet.b_Card .b_hList li.tall_wfn{width:80px;padding-right:6px}.b_imgSet.b_Card .b_hList li:last-child{padding-right:1px}.b_imgSet.b_Card .b_imgSetData{padding:0 8px 8px;height:40px}.b_imgSet.b_Card .b_imgSetItem{box-shadow:0 0 0 1px rgba(0,0,0,.05),0 2px 3px 0 rgba(0,0,0,.1);border-radius:6px;overflow:hidden}.b_imgSet .b_imgSetData p a{color:#444;outline-offset:0}.b_subModule .b_clearfix.b_mhdr .b_floatR .b_moreLink,.b_subModule .b_clearfix.b_mhdr .b_floatR .b_moreLink:visited,.b_subModule>.b_moreLink,.b_subModule>.b_moreLink:visited{color:#767676}.b_imgSet .cico.b_placeholder{display:flex;justify-content:center;background-color:#f5f5f5;background-clip:content-box}.b_imgSet .cico.b_placeholder a{display:flex}.b_imgSet .cico.b_placeholder a img{width:48px;height:48px;margin:auto}@media(max-width:1362.9px){#b_context .b_entityTP .b_imgSet li:nth-child(5){display:none}.b_imgSet .b_hList li.wide_m:nth-child(3){display:none}}@media(max-width:1274.9px){#b_context .b_entityTP .b_imgSet li:nth-child(4){display:none}.b_imgSet .b_hList li.wide_m:nth-child(2){display:none}}.rcimgcol{height:104px;padding-top:12px;padding-bottom:12px}.rcimgcol .b_imgSet{overflow:hidden}.rcimgcol .b_imgSet ul{overflow-x:auto;overflow-y:hidden;white-space:nowrap;padding-left:20px}.rcimgcol .b_imgSet ul::-webkit-scrollbar{-webkit-appearance:none}.rcimgcol .b_imgSet .b_hList>li{padding-right:2px}.rcimgcol .b_imgSet .cico{border-radius:0}.rcimgcol .b_imgSet .b_hList>li:first-child img{border-radius:6px 0 0 6px}.rcimgcol .b_imgSet .b_hList>li:last-child img{border-radius:0 6px 6px 0}.rcimgcol .rcimgcol .b_sideBleed{margin-left:0;margin-right:0}.rcimgcol .b_imgclgovr{cursor:pointer}.rcimgcol .b_imgclgovr .cico img:hover{transform:scale(1.05);transition:transform .5s ease}腾讯云深入protobuf(Protocol Buffers)原理:简化你的数据序列化 2024年11月4日 · Protocol buffers 是⼀种语⾔中⽴,平台⽆关,可扩展的序列化数据的格式,可⽤于通信协议, 数据存储 等。 Protocol buffers 在序列化数据具有灵活、⾼效的特点。 相⽐于 更多内容请查看https://cloud.tencent.com/developer/article/2463651
Protobuf序列化原理 Protobuf定义了sint32 / sint64类型表示负数,通过先采用Zigzag编码 (将有符号数转换成无符号数),再采用Varint编码,从而用于减少编码后的字节数。 Zigazg编码是一种变长的编码方式,其编码原理是使用无符号 更多内容请查看https://blog.csdn.net/weixin_43971373/article/details/119729776
深入理解 ProtoBuf 原理与工程实践(概述) ProtoBuf (Protocol Buffers)是一种跨平台、语言无关、可扩展的序列化结构数据的方法,可用于网络数据交换及存储。 在序列化结构化数据的机制中,ProtoBuf是灵活、高效、 更多内容请查看https://zhuanlan.zhihu.com/p/348831252
|
|