Maps contain a variable encoded length followed by the key and value types encoded in a single byte. Next comes the payload which is encoded in a similar way to the Binary protocol.
Length
Key Type
Value Type
Key 1
Value 1
...
Key n
Value n
Variable
4-bit
4-bit
Variable
Variable
Variable
Variable
However in the implementation, the byte containing the key type & value type is not present if the length is 0.
https://www.internalfb.com/intern/staticdocs/thrift/docs/spec/protocol/data/#map-1
It states that:
However in the implementation, the byte containing the key type & value type is not present if the length is 0.