Class Printed<K,​V>

  • Type Parameters:
    K - key type
    V - 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)
    • Constructor Detail

      • Printed

        protected Printed​(Printed<K,​V> printed)
        Copy constructor.
        Parameters:
        printed - instance of Printed to copy
    • Method Detail

      • toFile

        public static <K,​V> Printed<K,​V> toFile​(String filePath)
        Print the records of a KStream to a file.
        Type Parameters:
        K - key type
        V - value type
        Parameters:
        filePath - path of the file
        Returns:
        a new Printed instance
      • toSysOut

        public static <K,​V> Printed<K,​V> toSysOut()
        Print the records of a KStream to system out.
        Type Parameters:
        K - key type
        V - value type
        Returns:
        a new Printed instance
      • withLabel

        public Printed<K,​V> withLabel​(String label)
        Print the records of a KStream with the provided label.
        Parameters:
        label - label to use
        Returns:
        this
      • withKeyValueMapper

        public Printed<K,​V> withKeyValueMapper​(KeyValueMapper<? super K,​? super V,​String> mapper)
        Print the records of a 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.
        Parameters:
        mapper - mapper to use
        Returns:
        this
      • withName

        public Printed<K,​V> withName​(String processorName)
        Print the records of a KStream with provided processor name.
        Parameters:
        processorName - the processor name to be used. If null a default processor name will be generated
        Returns:
        this