asfgit closed pull request #6527: [hotfix] [docs] Fix ProcessWindowFunction code snippets. URL: https://github.com/apache/flink/pull/6527
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/docs/dev/stream/operators/windows.md b/docs/dev/stream/operators/windows.md index e5ec0091e07..bebc5dd260e 100644 --- a/docs/dev/stream/operators/windows.md +++ b/docs/dev/stream/operators/windows.md @@ -724,17 +724,19 @@ A `ProcessWindowFunction` can be defined and used like this: DataStream<Tuple2<String, Long>> input = ...; input - .keyBy(<key selector>) - .window(<window assigner>) - .process(new MyProcessWindowFunction()); + .keyBy(t -> t.f0) + .timeWindow(Time.minutes(5)) + .process(new MyProcessWindowFunction()); /* ... */ -public class MyProcessWindowFunction extends ProcessWindowFunction<Tuple<String, Long>, String, String, TimeWindow> { +public class MyProcessWindowFunction + extends ProcessWindowFunction<Tuple2<String, Long>, String, String, TimeWindow> { - void process(String key, Context context, Iterable<Tuple<String, Long>> input, Collector<String> out) { + @Override + public void process(String key, Context context, Iterable<Tuple2<String, Long>> input, Collector<String> out) { long count = 0; - for (Tuple<String, Long> in: input) { + for (Tuple2<String, Long> in: input) { count++; } out.collect("Window: " + context.window() + "count: " + count); @@ -749,9 +751,9 @@ public class MyProcessWindowFunction extends ProcessWindowFunction<Tuple<String, val input: DataStream[(String, Long)] = ... input - .keyBy(<key selector>) - .window(<window assigner>) - .process(new MyProcessWindowFunction()) + .keyBy(_._1) + .timeWindow(Time.minutes(5)) + .process(new MyProcessWindowFunction()) /* ... */ ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services