I think the parallel overhead is much more than the actual work, as you stated in the comments. So let your Stream do the job sequentially.
FYI: you should use Stream::concat because cutting operations such as Stream::limit can be bypassed with Stream::flatMap .
Stream::sorted collects each item in Stream in a List , sorts the List , and then clicks the items in the desired order through the pipeline. Then the elements are collected again. Thus, this can be avoided by collecting items in a List and sorting subsequently. Using List is a much better choice than using Set , because order matters (I know there is a LinkedHashSet , but you can't sort it).
This, in my opinion, is the cleanest and possibly the fastest solution, since we cannot prove it.
Stream<AppStory> appStr1 =StreamSupport.stream(splititerato1, false) .map(this::vertexToStory1); Stream<AppStory> appStr2 =StreamSupport.stream(splititerato2, false) .map(this::vertexToStory2); Stream<AppStory> appStr3 =StreamSupport.stream(splititerato3, false) .map(this::vertexToStory3); List<AppStory> stories = Stream.concat(Stream.concat(appStr1, appStr2), appStr3) .distinct().collect(Collectors.toList());
Flown source share