Skip to content

Performance considerations

Mahmoud Ben Hassine edited this page Sep 6, 2017 · 4 revisions

Some stateful operations of the Java 8 Stream API may require to process the entire stream to produce the expected result like sorted, distinct and others. Here is an extract from the official JavaDoc of the java.util.Stream package:

Stateful operations may need to process the entire input before producing a result. For example, one cannot produce any results from sorting a stream until one has seen all elements of the stream. As a result, under parallel computation, some pipelines containing stateful intermediate operations may require multiple passes on the data or may need to buffer significant data.

This is the same case for some components provided by the UnixStream API like reverse, tail, and uniq.

Please refer to Javadoc of each component for more details about its type (stateful or stateless).

Clone this wiki locally