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

Guozhang Wang commented on KAFKA-8584:
--------------------------------------

[~sbourke] sorry for being late on your comment. Some more context here: we 
have been moving our req / response protocol to auto-generated code: 
https://issues.apache.org/jira/browse/KAFKA-7830.

It basically moves the implementation of XXXRequest / XXXResponse classes to 
XXXRequest/Response.json, and `./gradlew clients:processMessages` will auto 
create the XXXRequestData/ResponseData under `clients/src/generated` from the 
defined json file. You can take a look at the source code under `generation` 
directory to checkpoint the auto-generation code, e.g. 
`MessageDataGenerator.java`.

Now the question is, for the `bytes` type defined in JSON, what's the field 
type in the generated corresponding code? Right now it is interpreted as 
`byte[]` in Java. But for ProduceRequest case, we want to allow this `bytes` 
type to be converted into `ByteBuffer` in java instead of byte array since that 
is the field type used in the request.

This would require us to add some flags optional in the json definition for 
`bytes` type, to indicate how to interpret it in the generated Java code.

> Allow "bytes" type to generated a ByteBuffer rather than byte arrays
> --------------------------------------------------------------------
>
>                 Key: KAFKA-8584
>                 URL: https://issues.apache.org/jira/browse/KAFKA-8584
>             Project: Kafka
>          Issue Type: Sub-task
>            Reporter: Guozhang Wang
>            Assignee: SuryaTeja Duggi
>            Priority: Major
>              Labels: newbie
>
> Right now in the RPC definition, type {{bytes}} would be translated into 
> {{byte[]}} in generated Java code. However, for some requests like 
> ProduceRequest#partitionData, the underlying type would better be a 
> ByteBuffer rather than a byte array.
> One proposal is to add an additional boolean tag {{useByteBuffer}} for 
> {{bytes}} type, which by default is false; when set to {{true}} set the 
> corresponding field to generate {{ByteBuffer}} instead of {{[]byte}}. 



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

Reply via email to