Table of Contents |
---|
This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.
Status
Current state: Under Discussion Accepted
Discussion thread: here
JIRA: here
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 | ||||
---|---|---|---|---|
| ||||
"[" + this.streamName + "]: " + mapper.apply(keyToPrint, valueToPrint) |
Public Interfaces
...
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 | ||||
---|---|---|---|---|
| ||||
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).