Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Stream-Graphs example #20885

Closed
ktoso opened this issue Jul 5, 2016 · 3 comments
Closed

Bug in Stream-Graphs example #20885

ktoso opened this issue Jul 5, 2016 · 3 comments
Labels
help wanted Issues that the core team will likely not have time to work on t:docs t:stream
Milestone

Comments

@ktoso
Copy link
Member

ktoso commented Jul 5, 2016

Reported by Sergey Sopin on akka-user.


It seems that one of examples in the documentation contains bug, namely: http://doc.akka.io/docs/akka/2.4.7/java/stream/stream-graphs.html

final Source<Integer, NotUsed> in = Source.from(Arrays.asList(1, 2, 3, 4, 5));
final Sink<List<String>, CompletionStage<List<String>>> sink = Sink.head();
final Sink<List<Integer>, CompletionStage<List<Integer>>> sink2 = Sink.head();
final Flow<Integer, Integer, NotUsed> f1 = Flow.of(Integer.class).map(elem -> elem + 10);
final Flow<Integer, Integer, NotUsed> f2 = Flow.of(Integer.class).map(elem -> elem + 20);
final Flow<Integer, String, NotUsed> f3 = Flow.of(Integer.class).map(elem -> elem.toString());
final Flow<Integer, Integer, NotUsed> f4 = Flow.of(Integer.class).map(elem -> elem + 30);

final RunnableGraph<CompletionStage<List<String>>> result =
  RunnableGraph.<CompletionStage<List<String>>>fromGraph(
    GraphDSL
      .create(
        sink,
        (builder, out) -> {
          final UniformFanOutShape<Integer, Integer> bcast = builder.add(Broadcast.create(2));
          final UniformFanInShape<Integer, Integer> merge = builder.add(Merge.create(2));

          final Outlet<Integer> source = builder.add(in).out();
          builder.from(source).via(builder.add(f1))
            .viaFanOut(bcast).via(builder.add(f2)).viaFanIn(merge)
            .via(builder.add(f3.grouped(1000))).to(out);
          builder.from(bcast).via(builder.add(f4)).toFanIn(merge);
          return ClosedShape.getInstance();
        }));

Here we define 'sink2' variable, but never use it. We are using 'out' variable instead, which is undefined.
Please fix this confusing thing when it will be possible.

Thanks,
Sergey

@ktoso ktoso added bug t:docs t:stream help wanted Issues that the core team will likely not have time to work on labels Jul 5, 2016
@ktoso ktoso added this to the 2.4.x milestone Jul 5, 2016
@gosubpl
Copy link
Contributor

gosubpl commented Jul 5, 2016

Actually out is a local variable for lambda function (builder, out) -> { }, it is defined as SinkShape - this is a consequence of definition of GraphDSL.create function. I will submit a PR soon that removes redundant sink2 and clarifies the role of out via a comment.

gosubpl added a commit to gosubpl/akka that referenced this issue Jul 6, 2016
@patriknw patriknw added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted and removed bug labels Jul 7, 2016
@patriknw
Copy link
Member

patriknw commented Jul 7, 2016

@ktoso issues in docs can by definition not be bug. Let's use bug for real production issues.

@ktoso
Copy link
Member Author

ktoso commented Jul 7, 2016

Right, sorry for abuse of tag

ktoso pushed a commit that referenced this issue Jul 8, 2016
#20894)

* #20885 small fix and clarification for Java stream-graphs example

* #20885 GraphDSLDocTest comment wording improved
@ktoso ktoso modified the milestones: 2.4.8, 2.4.x Jul 8, 2016
@ktoso ktoso removed the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Jul 8, 2016
@ktoso ktoso closed this as completed Jul 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that the core team will likely not have time to work on t:docs t:stream
Projects
None yet
Development

No branches or pull requests

3 participants