flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhue...@apache.org
Subject [1/3] flink git commit: [FLINK-3176] Improve documentation for window apply
Date Thu, 07 Jan 2016 18:01:20 GMT
Repository: flink
Updated Branches:
  refs/heads/release-0.10 f2de5f7f9 -> 06a87f2d9


[FLINK-3176] Improve documentation for window apply

This closes #1488


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

Branch: refs/heads/release-0.10
Commit: 9feac5ae5e3a5f66d2b5fe764a63ce763c1b4b82
Parents: f2de5f7
Author: rtudoran <tudoranradu@ymail.com>
Authored: Wed Jan 6 14:02:41 2016 +0100
Committer: Fabian Hueske <fhueske@apache.org>
Committed: Thu Jan 7 19:00:40 2016 +0100

----------------------------------------------------------------------
 docs/apis/streaming_guide.md | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/9feac5ae/docs/apis/streaming_guide.md
----------------------------------------------------------------------
diff --git a/docs/apis/streaming_guide.md b/docs/apis/streaming_guide.md
index 65ffa70..0ccd4d5 100644
--- a/docs/apis/streaming_guide.md
+++ b/docs/apis/streaming_guide.md
@@ -602,7 +602,7 @@ dataStream.windowAll(TumblingTimeWindows.of(Time.of(5, TimeUnit.SECONDS)));
// L
             <p>Applies a general function to the window as a whole. Below is a function
that manually sums the elements of a window.</p>
             <p><strong>Note:</strong> If you are using a windowAll transformation,
you need to use an AllWindowFunction instead.</p>
     {% highlight java %}
-windowedStream.apply (new WindowFunction<Tuple2<String,Integer>,Integer>, Tuple,
Window>() {
+windowedStream.apply (new WindowFunction<Tuple2<String,Integer>, Integer, Tuple,
Window>() {
     public void apply (Tuple tuple,
             Window window,
             Iterable<Tuple2<String, Integer>> values,
@@ -613,7 +613,20 @@ windowedStream.apply (new WindowFunction<Tuple2<String,Integer>,Integer>,
Tuple,
         }
         out.collect (new Integer(sum));
     }
-};
+});
+
+// applying an AllWindowFunction on non-keyed window stream
+allWindowedStream.apply (new AllWindowFunction<Tuple2<String,Integer>, Integer,
Window>() {
+    public void apply (Window window,
+            Iterable<Tuple2<String, Integer>> values,
+            Collector<Integer> out) throws Exception {
+        int sum = 0;
+        for (value t: values) {
+            sum += t.f1;
+        }
+        out.collect (new Integer(sum));
+    }
+});
     {% endhighlight %}
           </td>
         </tr>
@@ -965,7 +978,11 @@ dataStream.windowAll(TumblingTimeWindows.of(Time.of(5, TimeUnit.SECONDS)))
// La
             <p>Applies a general function to the window as a whole. Below is a function
that manually sums the elements of a window.</p>
             <p><strong>Note:</strong> If you are using a windowAll transformation,
you need to use an AllWindowFunction instead.</p>
     {% highlight scala %}
-windowedStream.apply { applyFunction }
+windowedStream.apply { WindowFunction }
+
+// applying an AllWindowFunction on non-keyed window stream
+allWindowedStream.apply { AllWindowFunction }
+
     {% endhighlight %}
           </td>
         </tr>


Mime
View raw message