flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] zentol commented on a change in pull request #6407: [FLINK-9877][docs] Add documentation page for different datastream joins
Date Mon, 30 Jul 2018 09:20:51 GMT
zentol commented on a change in pull request #6407: [FLINK-9877][docs] Add documentation page
for different datastream joins
URL: https://github.com/apache/flink/pull/6407#discussion_r206065096

 File path: docs/dev/stream/operators/joining.md
 @@ -0,0 +1,284 @@
+title: "Joining"
+nav-id: streaming_joins
+nav-show_overview: true
+nav-parent_id: streaming_operators
+nav-pos: 11
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+* toc
+# Window Join
+A window join joins the elements of two streams that share a common key and lie in the same
window. These windows can be defined by using a [window assigner]({{ site.baseurl}}/dev/stream/operators/windows.html#window-assigners)
and are evaluated on elements from both of the streams.
+The elements from both sides are then passed to a user-defined `JoinFunction` or `FlatJoinFunction`
where the user can emit results that meet the join criteria.
+The general usage can be summarized as follows:
+{% highlight java %}
+    .where(<KeySelector>)
+    .equalTo(<KeySelector>)
+    .window(<WindowAssigner>)
+    .apply(<JoinFunction>)
+{% endhighlight %}
+Some notes on semantics:
+- The creation of pairwise combinations of elements of the two streams behaves like an inner-join,
meaning elements from one stream will not be emitted if they don't have a corresponding element
from the other stream to be joined with.
+- Those elements that do get joined will have as their timestamp the largest timestamp that
still lies in the respective window. For example a window with `[5, 10)` as its boundaries
would result in the joined elements having 9 as their timestamp.
+In the following section we are going to give an overview over how different kinds of window
joins behave using some exemplary scenarios.
+## Tumbling Window Join
+When performing a tumbling window join, all elements with a common key and a common tumbling
window are joined as pairwise combinations and passed on to a `JoinFunction` or `FlatJoinFunction`.
Because this behaves like an inner join, elements of one stream that do not have elements
from another stream in their tumbling window are not emitted!
+<img src="{{ site.baseurl }}/fig/tumbling-window-join.svg" class="center" style="width:
80%;" />
+As illustrated in the figure, we define a tumbling window with the size of 2 milliseconds,
which results in windows of the form `[0,1], [2,3], ...`. The image shows the pairwise combinations
of all elements in each window which will be passed on to the `JoinFunction`. Note that in
the tumbling window `[6,7]` nothing is emitted because no elements exist in the green stream
to be joined with the orange elements ⑥ and ⑦.
+<div class="codetabs" markdown="1">
+<div data-lang="java" markdown="1">
+{% highlight java %}
+import org.apache.flink.api.java.functions.KeySelector;
+import org.apache.flink.streaming.api.windowing.assigners.TumblingEventTimeWindows;
+import org.apache.flink.streaming.api.windowing.time.Time;
+DataStream<Integer> orangeStream = ...
+DataStream<Integer> greenStream = ...
+    .where(<KeySelector>)
+    .equalTo(<KeySelector>)
+    .window(TumblingEventTimeWindows.of(Time.seconds(2)))
+    .apply (new JoinFunction<Integer, Integer, String> () {
 Review comment:
   remove space before `(`

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

View raw message