Table of Contents |
---|
Status
Current state: Under DiscussionAccepted
Discussion thread: here
JIRA: Jira server ASF JIRA serverId 5aa69414-a9e9-3523-82ec-879b028fb15b key KAFKA-8885
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
...
Each optional field has a 31-bit tag number. This number must be unique within the context it appears in. For example, we could use the tag number "1" both at the top level and within a particular substructure without creating ambiguity, since the contexts are separate.Optional Tagged fields can have any type, except that they cannot be arrays. Note that the restriction against having tagged arrays is just to simplify serialization. We can relax this restriction in the future without changing the protocol on the wire..
Here is an example of Here is an example of a message spec which has tagged fields at both the top level and the array level:
Code Block | ||
---|---|---|
| ||
{ "apiKey": 9000, "type": "response", "name": "FooResponse", "validVersions": "0-9", "flexibleVersions": "9+", "optionalFieldsfields": [ { { "name": "UserAgent", "type": "string", "tag": 0, "taggedVersions": "9+", "about": "The user-agent that sent this request." }, ], "fields": [ { "name": "Foos", "type": "[]Foo", "versions": "0+", "about": "Each foo.", "optionalFieldsfields": [ { "name": "Bar", "type": "string", "tag": 0": 0, "taggedVersions": "9+", "default": "hello world", "about": "The bar associated with this foo, if any." }, ], "fields": [ { "name": "Baz", "type": "int16", "versions": "0+", "about": "The baz associated with this foo." }, ... ] } |
Type Classes
...
Type Class Name | Field Class Name | Description |
---|---|---|
CompactArrayOf | CompactArray | Represents an array whose length is expressed as a variable-length integer rather than a fixed 4-byte length. |
COMPACT_STRING | CompactString | Represents a string whose length is expressed as a variable-length integer rather than a fixed 2-byte length. |
COMPACT_NULLABLE_STRING | CompactNullableString | Represents a nullable string whose length is expressed as a variable-length integer rather than a fixed 2-byte length. |
COMPACT_BYTES | CompactBytes | Represents a byte buffer whose length is expressed as a variable-length integer rather than a fixed 4-byte length. |
COMPACT_NULLABLE_BYTES | CompactNullableBytes | Represents a nullable byte buffer whose length is expressed as a variable-length integer rather than a fixed 4-byte length. |
TaggedFieldsTaggedFields | TaggedFieldsSection | Represents a section containing optional tagged fields. |
...