Thrift 格式规范在哪里?
尽管 Thrift 格式使用相对广泛(并且项目仍然存在),但我还没有找到底层数据格式的规范。或者格式,因为显然至少有两种格式;标准格式,紧凑格式。
鉴于它的广泛使用,我希望这只是我可怜的谷歌-fu,并且存在一个或多个规范(在源代码之外)。如果有,请分享!
编辑:Java 源代码对于确定格式来说还不错;参见 TBinaryProtocol.java 和 TCompactBinaryProtocol.java;其中包含由生成的类(扩展 TBase)调用的原语
EDIT2:虽然它不包含格式规范,但“缺少的指南”是很好的读物。
Although Thrift format is relatively widely used (and project still alive), I haven't been able to find specification for the underlying data format. Or formats, given that there are apparently at least two formats; standard one, and compact format.
Given its wide usage I am hoping it is just my poor google-fu, and a specification or specifications exist (outside of source code). If so, please share!
EDIT: Java source code is not too bad for figuring out format; see TBinaryProtocol.java and TCompactBinaryProtocol.java; which contain primitives, called by generated classes (which extend TBase)
EDIT2: While it does not contain format spec, "the missing guide" is good reading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题,因此决定编写 Thrift 二进制和紧凑协议的规范。
该规范现已在 Thrift 存储库中提供: https://github.com/ apache/thrift/tree/master/doc/specs
旧答案:
您可以在这里找到它:https://erikvanoosten.github.io/thrift-missing-specification/
I had the same problem and therefore decided to write a specification of the Thrift binary and compact protocol.
The spec is now available in the Thrift repo: https://github.com/apache/thrift/tree/master/doc/specs
Old answer:
You can find it here: https://erikvanoosten.github.io/thrift-missing-specification/
Thrift 消息的格式取决于所选的序列化协议。您可以使用多种协议之一序列化 Thrift 对象,包括 TBinaryProtocol、TCompactProtocol、TJSONProtocol 和其他晦涩的选项。该协议在原始的 Thrift 白皮书 PDF 中进行了抽象描述: API,但目前尚未在 Thrift apache 项目中的任何地方定义。
TCompactProtocol 协议在 thrift wiki 上的定义稍好一些,但并不简单。
在提供更好的文档之前,您还可以将 Python 库代码与 Python
struct
模块文档一起检查,作为另一种选择。The format for a Thrift message depends on the serialization protocol chosen. You can serialize a Thrift object using one of many protocols, including the TBinaryProtocol, TCompactProtocol, TJSONProtocol, and other obscure options. The protocol is described abstractly in the original Thrift Whitepaper PDF in terms of the API, but is not currently defined anywhere in the Thrift apache project.
The TCompactProtocol protocol is slightly better defined on the thrift wiki but not in simple terms.
Until better documentation is available, you can also examine the Python library code alongside the Python
struct
module documentation as another option.有两种二进制编码:紧凑型和非紧凑型。
通常你会在野外找到紧凑的协议:
虽然非紧凑协议可能是遗留协议:
这是该规范的粗略概述:
There are two binary encodings, compact and and non-compact.
Usually you will find the compact protocol in the wild:
While the non-compact protocol is probably a legacy protocol:
With this being a rough overview of the specification: