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

Jason Gustafson commented on KAFKA-8369:
----------------------------------------

[~Yohan123] Good question. My thought was that the key would be the field that 
is identified with the "mapKey" property in the schema definition. For example, 
take the following schema:
{code:java}
{
  "apiKey": 24,
  "type": "request",
  "name": "AddPartitionsToTxnRequest",
  // Version 1 is the same as version 0.                                        
                                                                                
                                
  "validVersions": "0-1",
  "fields": [
    { "name": "TransactionalId", "type": "string", "versions": "0+", 
"entityType": "transactionalId",
      "about": "The transactional id corresponding to the transaction."},
    { "name": "ProducerId", "type": "int64", "versions": "0+", "entityType": 
"producerId",
      "about": "Current producer id in use by the transactional id." },
    { "name": "ProducerEpoch", "type": "int16", "versions": "0+",
      "about": "Current epoch associated with the producer id." },
    { "name": "Topics", "type": "[]AddPartitionsToTxnTopic", "versions": "0+",
      "about": "The partitions to add to the transation.", "fields": [
      { "name": "Name", "type": "string", "versions": "0+", "mapKey": true, 
"entityType": "topicName",
        "about": "The name of the topic." },
      { "name": "Partitions", "type": "[]int32", "versions": "0+",
        "about": "The partition indexes to add to the transaction" }
    ]}
  ]
}{code}
In the topics array, the map key is the topic name. So what I was hoping to be 
able to get out of this would be something like `Map<String, List<Integer>>` or 
maybe `Map<String, AddPartitionsToTxnTopic>`. Does that make sense?

> Generate an immutable Map view for generated messages with a map key
> --------------------------------------------------------------------
>
>                 Key: KAFKA-8369
>                 URL: https://issues.apache.org/jira/browse/KAFKA-8369
>             Project: Kafka
>          Issue Type: Improvement
>            Reporter: Jason Gustafson
>            Priority: Major
>
> When using the "mapKey" feature, we get an ImplicitLinkedHashCollection which 
> can be used like a map using the `find()` API. The benefit of this is 
> hopefully avoiding a conversion to another type when handled by the broker, 
> but it is a little cumbersome to work with, so we often end up doing the 
> conversion anyway. One improvement would be to provide a way to convert this 
> collection to an immutable Map view so that it is easier to work with 
> directly.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to