unrdered() (original) (raw)
Brian Goetz brian.goetz at oracle.com
Wed Apr 3 19:34:25 PDT 2013
- Previous message: Javac internal error compiling lambdas
- Next message: unrdered()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At one point, we had an unordered() op. I think it may be time to bring it back.
There are a growing number of ops that have optimized implementations for unordered streams:
distinct can be implemented with concurrent insertion into a CHS instead of merging if we don't care about order. Not only is this less work (merging is expensive), but it makes distinct lazy (elements can flow through immediately once they've not been found in the CHS, instead of waiting for all the elements to be seen.)
sorted is non-stable in unordered streams.
limit/subsequence are far lighter for unordered streams (and can similarly be made lazy)
So a way of saying "I know you think this stream has ordering, but I don't care about it" is a way of opting into these optimizations.
Implementation is trivial.
Adding .unordered() could also enable us to get rid of .collectUnordered(), and allow more of the reduce-like ops to benefit from the embrace of "disorder" without API explosion.
- Previous message: Javac internal error compiling lambdas
- Next message: unrdered()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]