Thrift binary protocol

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m (Added Category:Apache)
(Removed no-longer-relevant (after further research in the course of writing the page) remark)
 
Line 7: Line 7:
  
 
== Identification ==
 
== Identification ==
In the new<ref name="commit">Commit 589859984f43af1ed0f9ee45ce8374a0d1640813</ref> ("strict") header type, binary protocol files start with a one-byte message type, a zero byte, and then the version indicator <code>0x01 0x00 0x00 0x08</code>.<ref>Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → definition of VERSION_MASK and VERSION_1, and of writeMessageBegin(). https://stackoverflow.com/questions/8402479/error-while-compiling-thrift-server indicates that the version/size integer is presumably stored [[endianness|little-endian]].</ref>. (This version indicator has been steady since at least as far back as 2011.) This is followed by an encoded string (a 32-bit length and series of bytes) and a 32-bit sequence ID.<ref>Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → readMessageBegin(); /lib/java/src/org/apache/thrift/protocol/TMessage.java</ref>
+
In the new<ref name="commit">Commit 589859984f43af1ed0f9ee45ce8374a0d1640813</ref> ("strict") header type, binary protocol files start with a one-byte message type, a zero byte, and then the version indicator <code>0x01 0x00 0x00 0x08</code>.<ref>Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → definition of VERSION_MASK and VERSION_1, and of writeMessageBegin(). https://stackoverflow.com/questions/8402479/error-while-compiling-thrift-server indicates that the version/size integer is presumably stored [[endianness|little-endian]].</ref>. This is followed by an encoded string (a 32-bit length and series of bytes) and a 32-bit sequence ID.<ref>Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → readMessageBegin(); /lib/java/src/org/apache/thrift/protocol/TMessage.java</ref>
  
 
In the old<ref name="commit" /> (non-"strict") header type, the message begins with the encoded string of the message name, followed by the type byte, followed by a 32-bit sequence ID.<ref>Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → readMessageBegin()</ref>
 
In the old<ref name="commit" /> (non-"strict") header type, the message begins with the encoded string of the message name, followed by the type byte, followed by a 32-bit sequence ID.<ref>Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → readMessageBegin()</ref>

Latest revision as of 05:25, 20 May 2019

File Format
Name Thrift binary protocol
Ontology
Released 2007

Apache Thrift, a serialization/RPC system with much more emphasis on RPC than serialization, calls its serialization formats "protocols"; the oldest Thrift-specific protocol is the "binary" protocol, while the newer one is the "compact" protocol.[1]

[edit] Identification

In the new[2] ("strict") header type, binary protocol files start with a one-byte message type, a zero byte, and then the version indicator 0x01 0x00 0x00 0x08.[3]. This is followed by an encoded string (a 32-bit length and series of bytes) and a 32-bit sequence ID.[4]

In the old[2] (non-"strict") header type, the message begins with the encoded string of the message name, followed by the type byte, followed by a 32-bit sequence ID.[5]

[edit] Links

[edit] References

  1. https://thrift.apache.org/docs/concepts#protocol
  2. 2.0 2.1 Commit 589859984f43af1ed0f9ee45ce8374a0d1640813
  3. Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → definition of VERSION_MASK and VERSION_1, and of writeMessageBegin(). https://stackoverflow.com/questions/8402479/error-while-compiling-thrift-server indicates that the version/size integer is presumably stored little-endian.
  4. Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → readMessageBegin(); /lib/java/src/org/apache/thrift/protocol/TMessage.java
  5. Thrift source → /lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java → readMessageBegin()
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox