[ 
https://issues.apache.org/jira/browse/KAFKA-19634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18023595#comment-18023595
 ] 

Jun Rao commented on KAFKA-19634:
---------------------------------

[~isding_l]:  Here is an example. ConsumerGroupHeartbeatResponse has a field 
Assignment, which is a nullable struct.

{code:java}
    { "name": "Assignment", "type": "Assignment", "versions": "0+", 
"nullableVersions": "0+", "default": "null",
      "about": "null if not provided; the assignment otherwise.", "fields": [
      { "name": "TopicPartitions", "type": "[]TopicPartitions", "versions": 
"0+",
        "about": "The partitions assigned to the member that can be used 
immediately." }
    ]}
{code}

The generated class ConsumerGroupHeartbeatResponseData has the following code 
for serialization related to a null value.

{code:java}
        if (assignment == null) {
            _writable.writeByte((byte) -1);
        } else {
            _writable.writeByte((byte) 1);
            assignment.write(_writable, _cache, _version);
        }
{code}


> document the encoding of nullable struct
> ----------------------------------------
>
>                 Key: KAFKA-19634
>                 URL: https://issues.apache.org/jira/browse/KAFKA-19634
>             Project: Kafka
>          Issue Type: Improvement
>            Reporter: Jun Rao
>            Assignee: Lan Ding
>            Priority: Major
>
> In [https://kafka.apache.org/protocol#protocol_types,] we didn't specify the 
> encoding of a struct. In particular, how a nullable struct is represented. We 
> should document that if a struct is nullable, the first byte indicates 
> whether is null and the rest of the bytes are the serialization of each field.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to