Repository: flink Updated Branches: refs/heads/master 17953d267 -> afd0f16b8
[FLINK-3881] [docs] Java 8 Documetation Sample Correction This closes #1970. Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/afd0f16b Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/afd0f16b Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/afd0f16b Branch: refs/heads/master Commit: afd0f16b89683212104e7f41dbd3b557b1f02cc5 Parents: 17953d2 Author: mans2singh <[email protected]> Authored: Sat May 7 12:08:02 2016 -0700 Committer: Till Rohrmann <[email protected]> Committed: Mon May 9 10:50:11 2016 +0200 ---------------------------------------------------------------------- docs/apis/java8.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/afd0f16b/docs/apis/java8.md ---------------------------------------------------------------------- diff --git a/docs/apis/java8.md b/docs/apis/java8.md index 821038b..c820355 100644 --- a/docs/apis/java8.md +++ b/docs/apis/java8.md @@ -53,29 +53,33 @@ If the `Collector` type can not be inferred from the surrounding context, it nee Otherwise the output will be treated as type `Object` which can lead to undesired behaviour. ~~~java -DataSet<String> input = env.fromElements(1, 2, 3); +DataSet<Integer> input = env.fromElements(1, 2, 3); // collector type must be declared input.flatMap((Integer number, Collector<String> out) -> { + StringBuilder builder = new StringBuilder(); for(int i = 0; i < number; i++) { - out.collect("a"); + builder.append("a"); + out.collect(builder.toString()); } }) -// returns "a", "a", "aa", "a", "aa" , "aaa" +// returns (on separate lines) "a", "a", "aa", "a", "aa", "aaa" .print(); ~~~ ~~~java -DataSet<String> input = env.fromElements(1, 2, 3); +DataSet<Integer> input = env.fromElements(1, 2, 3); // collector type must not be declared, it is inferred from the type of the dataset DataSet<String> manyALetters = input.flatMap((number, out) -> { + StringBuilder builder = new StringBuilder(); for(int i = 0; i < number; i++) { - out.collect("a"); + builder.append("a"); + out.collect(builder.toString()); } }); -// returns "a", "a", "aa", "a", "aa" , "aaa" +// returns (on separate lines) "a", "a", "aa", "a", "aa", "aaa" manyALetters.print(); ~~~
