K
- key typeV
- value typepublic class Printed<K,V>
extends java.lang.Object
KStream
.KStream.print(Printed)
Modifier and Type | Field | Description |
---|---|---|
protected java.lang.String |
label |
|
protected KeyValueMapper<? super K,? super V,java.lang.String> |
mapper |
|
protected java.io.OutputStream |
outputStream |
Modifier | Constructor | Description |
---|---|---|
protected |
Printed(Printed<K,V> printed) |
Copy constructor.
|
Modifier and Type | Method | Description |
---|---|---|
static <K,V> Printed<K,V> |
toFile(java.lang.String filePath) |
Print the records of a
KStream to a file. |
static <K,V> Printed<K,V> |
toSysOut() |
Print the records of a
KStream to system out. |
Printed<K,V> |
withKeyValueMapper(KeyValueMapper<? super K,? super V,java.lang.String> mapper) |
Print the records of a
KStream with the provided KeyValueMapper
The provided KeyValueMapper's mapped value type must be String . |
Printed<K,V> |
withLabel(java.lang.String label) |
Print the records of a
KStream with the provided label. |
protected final java.io.OutputStream outputStream
protected java.lang.String label
protected KeyValueMapper<? super K,? super V,java.lang.String> mapper
public static <K,V> Printed<K,V> toFile(java.lang.String filePath)
KStream
to a file.K
- key typeV
- value typefilePath
- path of the filepublic static <K,V> Printed<K,V> toSysOut()
KStream
to system out.K
- key typeV
- value typepublic Printed<K,V> withLabel(java.lang.String label)
KStream
with the provided label.label
- label to usepublic Printed<K,V> withKeyValueMapper(KeyValueMapper<? super K,? super V,java.lang.String> mapper)
KStream
with the provided KeyValueMapper
The provided KeyValueMapper's mapped value type must be String
.
The example below shows how to customize output data.
final KeyValueMapper<Integer, String, String> mapper = new KeyValueMapper<Integer, String, String>() {
public String apply(Integer key, String value) {
return String.format("(%d, %s)", key, value);
}
};
Implementors will need to override toString()
for keys and values that are not of type String
,
Integer
etc. to get meaningful information.mapper
- mapper to use