Skip to content

Commit

Permalink
Merge pull request akka#22956 from richard-imaoka/doc-22923-stream-ja…
Browse files Browse the repository at this point in the history
…va-tweet-imaoka

Fix text of stream-quickstart.rst for Java
  • Loading branch information
2m authored May 15, 2017
2 parents 1313771 + 4b1765e commit 3cbeb71
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions akka-docs/src/main/paradox/java/stream/stream-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,15 @@ First, let's write such an element counter using `Flow.of(Class)` and `Sink.fold

@@snip [TwitterStreamQuickstartDocTest.java]($code$/java/jdocs/stream/TwitterStreamQuickstartDocTest.java) { #tweets-fold-count }

First we prepare a reusable `Flow` that will change each incoming tweet into an integer of value `1`. We'll use this in
order to combine those with a `Sink.fold` that will sum all `Integer` elements of the stream and make its result available as
a `CompletionStage<Integer>`. Next we connect the `tweets` stream to `count` with `via`. Finally we connect the Flow to the previously
prepared Sink using `toMat`.
`Sink.fold` will sum all `Integer` elements of the stream and make its result available as
a `CompletionStage<Integer>`. Next we use the `map` method of `tweets` `Source` which will change each incoming tweet
into an integer value `1`. Finally we connect the Flow to the previously prepared Sink using `toMat`.

Remember those mysterious `Mat` type parameters on ``Source<Out, Mat>``, `Flow<In, Out, Mat>` and `Sink<In, Mat>`?
They represent the type of values these processing parts return when materialized. When you chain these together,
you can explicitly combine their materialized values: in our example we used the `Keep.right` predefined function,
you can explicitly combine their materialized values: in our example we used the `Keep.right()` predefined function,
which tells the implementation to only care about the materialized type of the stage currently appended to the right.
The materialized type of `sumSink` is `CompletionStage<Integer>` and because of using `Keep.right`, the resulting `RunnableGraph`
The materialized type of `sumSink` is `CompletionStage<Integer>` and because of using `Keep.right()`, the resulting `RunnableGraph`
has also a type parameter of `CompletionStage<Integer>`.

This step does *not* yet materialize the
Expand Down

0 comments on commit 3cbeb71

Please sign in to comment.