Fix incorrect materialized types = Unit in stream documentation (#21938)

* Fix incorrect materialized types = Unit in stream documentation (Fixes #21937)

*  Correct Int, which should be Integer in Java

* Replace BoxedUnit in stream doc
This commit is contained in:
Richard Imaoka 2016-12-06 23:52:54 +09:00 committed by Patrik Nordwall
parent c38d3850a2
commit 3df22baf3a
8 changed files with 15 additions and 15 deletions

View file

@ -243,19 +243,19 @@ public class CompositionDocTest extends AbstractJavaTest {
@Test
public void materializedValues() throws Exception {
//#mat-combine-1
// Materializes to Promise<BoxedUnit> (red)
// Materializes to CompletableFuture<Optional<Integer>> (red)
final Source<Integer, CompletableFuture<Optional<Integer>>> source = Source.<Integer>maybe();
// Materializes to BoxedUnit (black)
// Materializes to NotUsed (black)
final Flow<Integer, Integer, NotUsed> flow1 = Flow.of(Integer.class).take(100);
// Materializes to Promise<Option<>> (red)
// Materializes to CompletableFuture<Optional<Integer>> (red)
final Source<Integer, CompletableFuture<Optional<Integer>>> nestedSource =
source.viaMat(flow1, Keep.left()).named("nestedSource");
//#mat-combine-1
//#mat-combine-2
// Materializes to BoxedUnit (orange)
// Materializes to NotUsed (orange)
final Flow<Integer, ByteString, NotUsed> flow2 = Flow.of(Integer.class)
.map(i -> ByteString.fromString(i.toString()));

View file

@ -247,7 +247,7 @@ The propagation of the individual materialized values from the enclosed modules
|
To implement the above, first, we create a composite :class:`Source`, where the enclosed :class:`Source` have a
materialized type of :class:`Promise<BoxedUnit>`. By using the combiner function ``Keep.left()``, the resulting materialized
materialized type of :class:`CompletableFuture<Optional<Integer>>>`. By using the combiner function ``Keep.left()``, the resulting materialized
type is of the nested module (indicated by the color *red* on the diagram):
.. includecode:: ../code/docs/stream/CompositionDocTest.java#mat-combine-1

View file

@ -50,7 +50,7 @@ override ``onPull()`` which indicates that we are free to emit a single element.
``onDownstreamFinish()`` which is called if the downstream cancelled. Since the default behavior of that callback is
to stop the stage, we don't need to override it. In the ``onPull`` callback we simply emit the next number.
Instances of the above :class:`GraphStage` are subclasses of ``Graph<SourceShape<Int>,Unit>`` which means
Instances of the above :class:`GraphStage` are subclasses of ``Graph<SourceShape<Integer>,NotUsed>`` which means
that they are already usable in many situations, but do not provide the DSL methods we usually have for other
:class:`Source` s. In order to convert this :class:`Graph` to a proper :class:`Source` we need to wrap it using
``Source.fromGraph`` (see :ref:`composition-java` for more details about graphs and DSLs). Now we can use the
@ -379,7 +379,7 @@ or ``unwatch(ref)`` methods. The reference can be also watched by external actor
Custom materialized values
--------------------------
Custom stages can return materialized values instead of ``Unit`` by inheriting from :class:`GraphStageWithMaterializedValue`
Custom stages can return materialized values instead of ``NotUsed`` by inheriting from :class:`GraphStageWithMaterializedValue`
instead of the simpler :class:`GraphStage`. The difference is that in this case the method
``createLogicAndMaterializedValue(inheritedAttributes)`` needs to be overridden, and in addition to the
stage logic the materialized value must be provided

View file

@ -184,7 +184,7 @@ more advanced graph elements to finally be consumed by a ``Sink<In,M3>``.
The first type parameter—:class:`Tweet` in this case—designates the kind of elements produced
by the source while the ``M`` type parameters describe the object that is created during
materialization (:ref:`see below <materialized-values-quick-java>`)—:class:`BoxedUnit` (from the ``scala.runtime``
materialization (:ref:`see below <materialized-values-quick-java>`)—:class:`NotUsed` (from the ``scala.runtime``
package) means that no value is produced, it is the generic equivalent of ``void``.
The operations should look familiar to anyone who has used the Scala Collections library,
@ -251,7 +251,7 @@ Graphs are constructed using :class:`GraphDSL` like this:
As you can see, we use graph builder ``b`` to construct the graph using ``UniformFanOutShape`` and ``Flow`` s.
``GraphDSL.create`` returns a :class:`Graph`, in this example a ``Graph<ClosedShape,Unit>`` where
``GraphDSL.create`` returns a :class:`Graph`, in this example a ``Graph<ClosedShape,NotUsed>`` where
:class:`ClosedShape` means that it is *a fully connected graph* or "closed" - there are no unconnected inputs or outputs.
Since it is closed it is possible to transform the graph into a :class:`RunnableGraph` using ``RunnableGraph.fromGraph``.
The runnable graph can then be ``run()`` to materialize a stream out of it.