wire / wire-format / thrift-binary

Thrift binary protocol

Apache Thrift's binary protocol encodes each field as: 1-byte type, 2-byte field ID (big-endian), then the value. A struct is a sequence of fields terminated by a STOP (type 0). Types: 0 STOP, 1 VOID, 2 BOOL, 3 BYTE, 4 I16, 5 I32, 6 I64, 7 DOUBLE, 8 STRING (4-byte length + bytes), 9 MAP, 10 SET, 11 LIST, 12 STRUCT, 13 UUID (16 bytes).

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: Thrift binary protocol

wire format

spec: Apache Thrift

Apache Thrift's binary protocol encodes each field as: 1-byte type, 2-byte field ID (big-endian), then the value. A struct is a sequence of fields terminated by a STOP (type 0). Types: 0 STOP, 1 VOID, 2 BOOL, 3 BYTE, 4 I16, 5 I32, 6 I64, 7 DOUBLE, 8 STRING (4-byte length + bytes), 9 MAP, 10 SET, 11 LIST, 12 STRUCT, 13 UUID (16 bytes).

fieldsizemeaning
Field type1 byte0 STOP, 1 VOID, 2 BOOL, 3 BYTE, 4 I16, 5 I32, 6 I64, 7 DOUBLE, 8 STRING, 9 MAP, 10 SET, 11 LIST, 12 STRUCT, 13 UUID.
Field ID2 bytes (int16, big-endian)Field identifier from the Thrift IDL.
ValuevariableType-specific encoding (see below).
BOOL1 byte0x00 = false, 0x01 = true.
I16/I32/I642/4/8 bytesSigned integer, big-endian.
DOUBLE8 bytesIEEE 754 double, big-endian.
STRING/BINARY4 bytes (int32) + dataLength-prefixed UTF-8 string or binary blob.
MAPvariable1-byte key type, 1-byte value type, 4-byte count, then key-value pairs.
LIST/SETvariable1-byte element type, 4-byte count, then elements.
STRUCTvariableNested fields (same format), terminated by STOP (0x00 type + 0x0000 field ID).

example:

00 00 00

Empty struct: STOP (type 0, field ID 0)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/thrift-binary or /wire-format/thrift-binary.json