Quantcast
Viewing latest article 12
Browse Latest Browse All 485

Answer by Federico klez Culloca for when do we really benfit from java stream.unordered()?

A per the documentation on stream ordering (emphasis mine):

For parallel streams, relaxing the ordering constraint can sometimes enable more efficient execution. Certain aggregate operations, such as filtering duplicates (distinct()) or grouped reductions (Collectors.groupingBy()) can be implemented more efficiently if ordering of elements is not relevant. Similarly, operations that are intrinsically tied to encounter order, such as limit(), may require buffering to ensure proper ordering, undermining the benefit of parallelism. In cases where the stream has an encounter order, but the user does not particularly care about that encounter order, explicitly de-ordering the stream with unordered() may improve parallel performance for some stateful or terminal operations.


Viewing latest article 12
Browse Latest Browse All 485

Trending Articles