@Public public class JoinedStreams<T1,T2> extends Object
JoinedStreams
represents two DataStreams
that have been joined.
A streaming join operation is evaluated over elements in a window.
To finalize the join operation you also need to specify a KeySelector
for
both the first and second input and a WindowAssigner
.
Note: Right now, the join is being evaluated in memory so you need to ensure that the number of elements per key does not get too high. Otherwise the JVM might crash.
Example:
DataStream<Tuple2<String, Integer>> one = ...;
DataStream<Tuple2<String, Integer>> twp = ...;
DataStream<T> result = one.join(two)
.where(new MyFirstKeySelector())
.equalTo(new MyFirstKeySelector())
.window(TumblingEventTimeWindows.of(Time.of(5, TimeUnit.SECONDS)))
.apply(new MyJoinFunction());
限定符和类型 | 类和说明 |
---|---|
class |
JoinedStreams.Where<KEY>
Joined streams that have the key for one side defined.
|
static class |
JoinedStreams.WithWindow<T1,T2,KEY,W extends Window>
A join operation that has
KeySelectors defined for both inputs as
well as a WindowAssigner . |
构造器和说明 |
---|
JoinedStreams(DataStream<T1> input1,
DataStream<T2> input2)
Creates new JoinedStreams data streams, which are the first step towards building a streaming co-group.
|
限定符和类型 | 方法和说明 |
---|---|
<KEY> JoinedStreams.Where<KEY> |
where(org.apache.flink.api.java.functions.KeySelector<T1,KEY> keySelector)
Specifies a
KeySelector for elements from the first input. |
<KEY> JoinedStreams.Where<KEY> |
where(org.apache.flink.api.java.functions.KeySelector<T1,KEY> keySelector,
org.apache.flink.api.common.typeinfo.TypeInformation<KEY> keyType)
Specifies a
KeySelector for elements from the first input with explicit type information for the key type. |
public JoinedStreams(DataStream<T1> input1, DataStream<T2> input2)
input1
- The first data stream.input2
- The second data stream.public <KEY> JoinedStreams.Where<KEY> where(org.apache.flink.api.java.functions.KeySelector<T1,KEY> keySelector)
KeySelector
for elements from the first input.keySelector
- The KeySelector to be used for extracting the key for partitioning.public <KEY> JoinedStreams.Where<KEY> where(org.apache.flink.api.java.functions.KeySelector<T1,KEY> keySelector, org.apache.flink.api.common.typeinfo.TypeInformation<KEY> keyType)
KeySelector
for elements from the first input with explicit type information for the key type.keySelector
- The KeySelector to be used for extracting the first input's key for partitioning.keyType
- The type information describing the key type.Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.