Dear all,

The following describes KIP-132, which I just created. See:
https://cwiki.apache.org/confluence/display/KAFKA/KIP-132+-+Augment+KStream.print+to+allow+extra+parameters+in+the+printed+string

Motivation

As for now, KStream#print leads to a predefined output where key and value are
printed with comma separation.
KAFKA-4830 <https://issues.apache.org/jira/browse/KAFKA-4830> suggests to
extend print in a way that it takes KeyValueMapper as a parameter.
This will allow a user to change outputs according to the users demand.
Public Interfaces

The affected interface is KStream, which needs to be extended with another
overloaded version of print:

void print(final Serde<K> keySerde,
           final Serde<V> valSerde,
           final String streamName,
           final KeyValueMapper<K, V, String> mapper);

Proposed Changes

See pull request GH-2669 <https://github.com/apache/kafka/pull/2669>.
This PR contains a discussion regarding KAFKA-4830
<https://issues.apache.org/jira/browse/KAFKA-4830> as well as KAFKA-4772
<https://issues.apache.org/jira/browse/KAFKA-4772>.

Compatibility, Deprecation, and Migration Plan

The extension of print will not introduce compatibility issues – we can
maintain the current output by keeping the current output format as a
default (if mapper was not set):

if(mapper == null) {
    printStream.println("[" + streamName + "]: " + keyToPrint + " , "
+ valueToPrint);
} else {
    printStream.println("[" + streamName + "]: " +
mapper.apply(keyToPrint, valueToPrint));
}



Kind regards,
Marc

Reply via email to