September 2017
Beginner to intermediate
360 pages
8h 13m
English
The merge operation is used to merge more than one stream together. Code example:
topology.merge(stream1, stream2, stream3);
Another way to combine streams is using join. Let's take an example: stream1 has the fields (key, val1, val2) and stream2 has (x, val1). Now perform a join with stream1 and stream2 as follows:
topology.join(stream1, new Fields("key"), stream2, new Fields("x"), new Fields("key", "a", "b", "c"));
The stream1 and stream2 are joined on the basis of key and x respectively. The output of the field is defined as key from stream1, val1, and val2 as a and b from stream1 again, val1 as c from stream2.
Input:
Stream 1:[1, 2, 3]Stream 2:[1, 4]
Output:
[1, 2, 3, 4]
Read now
Unlock full access