flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aljoscha <...@git.apache.org>
Subject [GitHub] flink pull request #4634: [FLINK-7568] Improve Windowing Documentation
Date Mon, 04 Sep 2017 16:35:44 GMT
Github user aljoscha commented on a diff in the pull request:

    --- Diff: docs/dev/stream/operators/windows.md ---
    @@ -663,25 +623,42 @@ input
         .keyBy(<key selector>)
         .window(<window assigner>)
         .process(new MyProcessWindowFunction())
    +/* ... */
    +class MyWindowFunction extends ProcessWindowFunction[(String, Long), String, String,
TimeWindow] {
    +  def apply(key: String, context: Context, input: Iterable[(String, Long)], out: Collector[String]):
() = {
    +    var count = 0L
    +    for (in <- input) {
    +      count = count + 1
    +    }
    +    out.collect(s"Window ${context.window} count: $count")
    +  }
     {% endhighlight %}
    -### WindowFunction with Incremental Aggregation
    +The example shows a `ProcessWindowFunction` that counts the elements in a window. In
addition, the window function adds information about the window to the output.
    +<span class="label label-danger">Attention</span> Note that using `ProcessWindowFunction`
for simple aggregates such as count is quite inefficient. The next section shows how a `ReduceFunction`
can be combined with a `ProcessWindowFunction` to get both incremental aggregation and the
added information of a `ProcessWindowFunction`.
    -A `WindowFunction` can be combined with either a `ReduceFunction` or a `FoldFunction`
    +### ProcessWindowFunction with Incremental Aggregation
    +A `ProcessWindowFunction` can be combined with either a `ReduceFunction` or a `FoldFunction`
    --- End diff --
    Ha! You went straight for the points that I wanted to do as follow-up work. I keep both
AggregateFunction and a more thorough discussion of per-window/global state out of this and
simply tried to bring the doc up to date and prepare it for those further changes. What do
you think?


View raw message