Skip to content

Java 8 Stream Documentation improvements #298

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

Merged
merged 7 commits into from
Feb 11, 2019

Conversation

gmessner
Copy link
Collaborator

Clarifies the use of Streams for both eager and lazy evaluation uses.

```java
// Stream the visible Projects printing out the project name.
gitlabApi.getProjectsApi().getProjectsStream().map(Project::getName).forEach(name -> System.out.println(name));
Stream projectsStream<Project> = gitlabApi.getProjectApi().getProjectsStream();
projectsStream.map(Project::getName).forEach(name -> System.out.println(name));

// Operate on the stream in parallel, this example sorts User instances by username
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a good idea to give such an example here. Parallel operations are generally used for performance optimization, but here project gathering is so slow, that this operation doesn't add any improvement. As a result, the user can be confused that this operation can be super fast and this library can fetch data in multiple channels.

Copy link
Collaborator Author

@gmessner gmessner Feb 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parallel operations are often performed after fetching the data, parallel operations are not only used to speed up fetching, I have added more info to make the fact that reading of the data for the Stream cannot be done in parallel.

@gmessner gmessner merged commit 9f96966 into master Feb 11, 2019
@gmessner
Copy link
Collaborator Author

@mariuszs
Thanks for all your input.

@gmessner gmessner deleted the issue/lazy-stream-evaluation branch May 5, 2019 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants