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

Marc Juchli edited comment on KAFKA-4830 at 3/3/17 2:41 PM:
------------------------------------------------------------

I'd like to tackle this, but beforehand I have a question. 
I see that your mentioned line of code is part of {{KeyValuePrinter}}, and now 
I am unsure whether this was just an example.
If my understanding is correct, what was suggested with 
{{KStream.print(KeyValueMapper<K, V, String>)}} is meant to be an extension of 
{{KStream}} in order to let the user decide how the output of the K,V shall 
look like. However, this rises my concerns as we wouldn't allow to set a 
{{streamName}} with this function definition.
Therefore, my approach would be to extend KStream with {{void print(final 
String streamName, final KeyValueMapper<K,V,String> mapper)}}.
Furthermore, as {{KStreamImpl.print}} creates an instance of 
{{KeyValuePrinter}}, this class would have to be changed too accordingly. Or is 
that meant be left open to the user?


was (Author: mjuchli):
I'd like to tackle this, but beforehand I have a question. 
I see that your mentioned line of code is part of {{KeyValuePrinter}}, and now 
I am unsure whether this was just an example.
If my understanding is correct, what was suggested with 
{{KStream.print(KeyValueMapper<K, V, String>)}} is meant to be an extension of 
{{KStream}} in order to let the user decide how the output of the K,V shall 
look like. However, this rises my concerns as we wouldn't allow to set a 
{{streamName}} with this function definition.
Therefore, my approach would be to extend KStream with {{void print(final 
String streamName, final KeyValueMapper<K,V,String> mapper)}}.
Furthermore, as {{KStreamImpl.print}} creates an instance of `KeyValuePrinter`, 
this class would have to be changed too accordingly. Or is that meant be left 
open to the user?

> Augment KStream.print() to allow users pass in extra parameters in the 
> printed string
> -------------------------------------------------------------------------------------
>
>                 Key: KAFKA-4830
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4830
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>            Reporter: Guozhang Wang
>              Labels: newbie
>
> Today {{KStream.print}} use the hard-coded result string as:
> {code}
> "[" + this.streamName + "]: " + keyToPrint + " , " + valueToPrint
> {code}
> And some users are asking to augment this so that they can customize the 
> output string as {{KStream.print(KeyValueMapper<K, V, String>):
> {code}
> "[" + this.streamName + "]: " + mapper.apply(keyToPrint, valueToPrint)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to