Nicholas Telford created KAFKA-13633:
----------------------------------------

             Summary: Merging multiple KStreams in one operation
                 Key: KAFKA-13633
                 URL: https://issues.apache.org/jira/browse/KAFKA-13633
             Project: Kafka
          Issue Type: Improvement
          Components: streams
    Affects Versions: 3.1.0
            Reporter: Nicholas Telford
            Assignee: Nicholas Telford


The {{KStream}} API provides {{merge(KStream)}} to merge another {{KStream}} 
with {{{}this{}}}. Sometimes, it may be useful to merge more than 2 
{{{}KStream{}}}s together. Currently, the best way to do this is using Java's 
{{{}Stream.reduce{}}}:
{noformat}
List<KStream<K, V>> streams ...;

streams.stream().reduce((left, right) -> left.merge(right));{noformat}
This creates a {{merge}} node in the process graph for every {{KStream}} in the 
collection being merged.

Complex process graphs can make understanding an application and debugging more 
difficult, therefore, we propose a new API that creates a single {{merge}} node 
in the process graph, irrespective of the number of {{{}KStream{}}}s being 
merged:
{noformat}
KStream<K, V> merge(KStream<K, V>... streams);
KStream<K, V> merge(Collection<K, V> streams, Named named);{noformat}
Note: since the varargs variant would conflict with the singleton API that 
presently exists, the varargs variant would _replace_ the existing singleton 
API:
{noformat}
KStream<K, V> merge(KStream<K, V> stream);{noformat}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to