flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aljos...@apache.org
Subject [1/2] flink git commit: [FLINK-4282] Add doc for WindowAssigner offset parameter
Date Fri, 19 Aug 2016 16:24:03 GMT
Repository: flink
Updated Branches:
  refs/heads/master 3be9a2851 -> 7e8de772b


[FLINK-4282] Add doc for WindowAssigner offset parameter

This closes #2333
This closes #2355


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/7e8de772
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/7e8de772
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/7e8de772

Branch: refs/heads/master
Commit: 7e8de772b00bbdaae5f606d51f3037c0ae5f8aae
Parents: 0977462
Author: Aljoscha Krettek <aljoscha.krettek@gmail.com>
Authored: Fri Aug 19 15:41:08 2016 +0200
Committer: Aljoscha Krettek <aljoscha.krettek@gmail.com>
Committed: Fri Aug 19 18:23:38 2016 +0200

----------------------------------------------------------------------
 docs/apis/streaming/windows.md | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/7e8de772/docs/apis/streaming/windows.md
----------------------------------------------------------------------
diff --git a/docs/apis/streaming/windows.md b/docs/apis/streaming/windows.md
index 7a93723..b9847a5 100644
--- a/docs/apis/streaming/windows.md
+++ b/docs/apis/streaming/windows.md
@@ -252,6 +252,42 @@ input
 Note, how we can specify a time interval by using one of `Time.milliseconds(x)`, `Time.seconds(x)`,
 `Time.minutes(x)`, and so on.
 
+The time-based window assigners also take an optional `offset` parameter that can be used
to
+change the alignment of windows. For example, without offsets hourly windows are aligned
+with epoch, that is you will get windows such as `1:00 - 1:59`, `2:00 - 2:59` and so on.
If you
+want to change that you can give an offset. With an offset of 15 minutes you would, for example,
+get `1:15 - 2:14`, `2:15 - 3:14` etc. Another important use case for offsets is when you
+want to have daily windows and live in a timezone other than UTC-0. For example, in China
+you would have to specify an offset of `Time.hours(-8)`.
+
+This example shows how an offset can be specified for tumbling event time windows (the other
+windows work accordingly):
+<div class="codetabs" markdown="1">
+<div data-lang="java" markdown="1">
+{% highlight java %}
+DataStream<T> input = ...;
+
+// tumbling event-time windows
+input
+    .keyBy(<key selector>)
+    .window(TumblingEventTimeWindows.of(Time.days(1), Time.hours(-8)))
+    .<windowed transformation>(<window function>);
+{% endhighlight %}
+</div>
+
+<div data-lang="scala" markdown="1">
+{% highlight scala %}
+val input: DataStream[T] = ...
+
+// tumbling event-time windows
+input
+    .keyBy(<key selector>)
+    .window(TumblingEventTimeWindows.of(Time.days(1), Time.hours(-8)))
+    .<windowed transformation>(<window function>)
+{% endhighlight %}
+</div>
+</div>
+
 ## Window Functions
 
 The *window function* is used to process the elements of each window (and key) once the system


Mime
View raw message