Package org.apache.kafka.streams.kstream
Class Printed<K,V>
java.lang.Object
org.apache.kafka.streams.kstream.Printed<K,V>
- Type Parameters:
K
- key typeV
- value type
public class Printed<K,V> extends Object
An object to define the options used when printing a
KStream
.- See Also:
KStream.print(Printed)
-
Field Summary
Fields Modifier and Type Field Description protected String
label
protected KeyValueMapper<? super K,? super V,String>
mapper
protected OutputStream
outputStream
protected String
processorName
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description static <K, V> Printed<K,V>
toFile(String filePath)
Print the records of aKStream
to a file.static <K, V> Printed<K,V>
toSysOut()
Print the records of aKStream
to system out.Printed<K,V>
withKeyValueMapper(KeyValueMapper<? super K,? super V,String> mapper)
Print the records of aKStream
with the providedKeyValueMapper
The provided KeyValueMapper's mapped value type must beString
.Printed<K,V>
withLabel(String label)
Print the records of aKStream
with the provided label.Printed<K,V>
withName(String processorName)
Print the records of aKStream
with provided processor name.
-
Field Details
-
outputStream
-
label
-
processorName
-
mapper
-
-
Constructor Details
-
Printed
Copy constructor.- Parameters:
printed
- instance ofPrinted
to copy
-
-
Method Details
-
toFile
Print the records of aKStream
to a file.- Type Parameters:
K
- key typeV
- value type- Parameters:
filePath
- path of the file- Returns:
- a new Printed instance
-
toSysOut
Print the records of aKStream
to system out.- Type Parameters:
K
- key typeV
- value type- Returns:
- a new Printed instance
-
withLabel
Print the records of aKStream
with the provided label.- Parameters:
label
- label to use- Returns:
- this
-
withKeyValueMapper
Print the records of aKStream
with the providedKeyValueMapper
The provided KeyValueMapper's mapped value type must beString
.The example below shows how to customize output data.
Implementors will need to overridefinal KeyValueMapper<Integer, String, String> mapper = new KeyValueMapper<Integer, String, String>() { public String apply(Integer key, String value) { return String.format("(%d, %s)", key, value); } };
toString()
for keys and values that are not of typeString
,Integer
etc. to get meaningful information.- Parameters:
mapper
- mapper to use- Returns:
- this
-
withName
Print the records of aKStream
with provided processor name.- Parameters:
processorName
- the processor name to be used. Ifnull
a default processor name will be generated- Returns:
- this
-