Class CoGroupedStreams<T1,T2>
java.lang.Object
org.apache.flink.streaming.api.datastream.CoGroupedStreams<T1,T2>
CoGroupedStreams represents two DataStreams that have been co-grouped.
A streaming co-group operation is evaluated over elements in a window.
To finalize co-group operation you also need to specify a KeySelector for both the
first and second input and a WindowAssigner.
Note: Right now, the groups are being built in memory so you need to ensure that they don't get too big. Otherwise the JVM might crash.
Example:
DataStream<Tuple2<String, Integer>> one = ...;
DataStream<Tuple2<String, Integer>> two = ...;
DataStream<T> result = one.coGroup(two)
.where(new MyFirstKeySelector())
.equalTo(new MyFirstKeySelector())
.window(TumblingEventTimeWindows.of(Duration.ofSeconds(5)))
.apply(new MyCoGroupFunction());
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTypeSerializerforTaggedUnion.static classTheTypeSerializerSnapshotfor theCoGroupedStreams.UnionSerializer.classCoGrouped streams that have the key for one side defined.static classA co-group operation that hasKeySelectorsdefined for both inputs as well as aWindowAssigner. -
Constructor Summary
ConstructorsConstructorDescriptionCoGroupedStreams(DataStream<T1> input1, DataStream<T2> input2) Creates new CoGrouped data streams, which are the first step towards building a streaming co-group. -
Method Summary
Modifier and TypeMethodDescription<KEY> CoGroupedStreams<T1,T2>.Where<KEY> Specifies aKeySelectorfor elements from the first input.<KEY> CoGroupedStreams<T1,T2>.Where<KEY> where(org.apache.flink.api.java.functions.KeySelector<T1, KEY> keySelector, org.apache.flink.api.common.typeinfo.TypeInformation<KEY> keyType) Specifies aKeySelectorfor elements from the first input with explicit type information.
-
Constructor Details
-
CoGroupedStreams
Creates new CoGrouped data streams, which are the first step towards building a streaming co-group.- Parameters:
input1- The first data stream.input2- The second data stream.
-
-
Method Details
-
where
public <KEY> CoGroupedStreams<T1,T2>.Where<KEY> where(org.apache.flink.api.java.functions.KeySelector<T1, KEY> keySelector) Specifies aKeySelectorfor elements from the first input.- Parameters:
keySelector- The KeySelector to be used for extracting the first input's key for partitioning.
-
where
public <KEY> CoGroupedStreams<T1,T2>.Where<KEY> where(org.apache.flink.api.java.functions.KeySelector<T1, KEY> keySelector, org.apache.flink.api.common.typeinfo.TypeInformation<KEY> keyType) Specifies aKeySelectorfor elements from the first input with explicit type information.- Parameters:
keySelector- The KeySelector to be used for extracting the first input's key for partitioning.keyType- The type information describing the key type.
-