This is an optimization that is theoretically possible (and was anticipated in the design), but in reality is likely to be so low-priority that it would be a really long time before it was worth putting engineering resources on this. It would have to be an unordered stream, and we'd have to know that the downstream pipeline is short-circuiting. (There is some back-propagation of characteristics for situations like this, but we have to be careful not to tax startup of common pipelines like filter-map-reduce just to support weird pipelines like this.)

On 5/6/2014 5:30 AM, Florian Weimer wrote:
On 05/05/2014 03:16 PM, Paul Sandoz wrote:
Hi,

   https://bugs.openjdk.java.net/browse/JDK-8042355

http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8042355-sorted-short-circuit/webrev/


This is an optimization to ensure that sorted() in sequential
pipelines does not aggressively push all sorted elements downstream if
the pipeline is known to be short-circuiting.

Would it be possible to use something like heap sort to avoid sorting
the entire input stream if only the first few smallest items are needed?

Reply via email to