Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Status

Current stateDiscussion

...

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

KStream#print() prints records on console; But the output from KStream#print() is fixed, some user maybe want to customize it.

...

Code Block
languagejava
themeEclipse
"[" + this.streamName + "]: " + mapper.apply(keyToPrint, valueToPrint)

 

With above idea, we also can apply this on KStream#writeAsText() to allow user customized output string written to file.

Public Interfaces

Expanding KStream#print() and KStream#writeAsText() which also need to be extended another version of print.

Code Block
languagejava
themeEclipse
void print(final KeyValueMapper<? super K, ? super V, String> mapper);
 
void print(final KeyValueMapper<? super K, ? super V, String> mapper, final String streamName);
 
void print(final KeyValueMapper<? super K, ? super V, String> mapper, final Serde<K> keySerde, final Serde<V> valSerde);
 
void print(final KeyValueMapper<? super K, ? super V, String> mapper, final Serde<K> keySerde, final Serde<V> valSerde, final String streamName);
 
void writeAsText(final String filePath, final KeyValueMapper<? super K, ? super V, String> mapper);
 
void writeAsText(final String filePath, final String streamName, final KeyValueMapper<? super K, ? super V, String> mapper);
 
void writeAsText(final String filePath, final Serde<K> keySerde, final Serde<V> valSerde, final KeyValueMapper<? super K, ? super V, String> mapper);
 
void writeAsText(final String filePath, String streamName, final Serde<K> keySerde, final Serde<V> valSerde, final KeyValueMapper<? super K, ? super V, String> mapper);

Proposed Changes

A straightforward first pass is on GitHub PR#3085.

Compatibility, Deprecation, and Migration Plan

No compatibility issues foreseen.

Rejected Alternatives

Base on KStream#print() and KStream#writeAsText(), some users seek for a new option which can customize the output but not should be restricted by fixed format.

To let user can customize output we think argument KStream#print() is  and KStream#writeAsText() is best option for usage(Intuition) and implementation(expand exist method with adding argument).