nus-cs2030 / 2122-s2

CS2030 repository and wiki for AY 2021/2022 Sem 2
MIT License
0 stars 0 forks source link

What kind of stream operations allow us to use .parallel() operation? #609

Open jkjliang opened 2 years ago

jkjliang commented 2 years ago

Would just like to get clarification regarding some examples of operations that are allowed> (according to the slides it says they need to be stateless and not interfere with stream data but I'm still not too sure what kind of operations fall under those categories)

image

eugenetaan commented 2 years ago

Hi, what i understand is that in general operations that are associative are able to run in parallel. But for stateful operations like sorting where order matters you cant run it in parallel.

Edit: Yea sorry its associative, https://stackoverflow.com/questions/45054372/what-do-the-stream-reduce-requirements-exactly-entail, I think this post explains it pretty well

Brianliew77 commented 2 years ago

Operations that are associative can run in parallel. Hope this helps

e0415501 commented 2 years ago

It seems that all Streams can run in parallel? When you create a stream, it is always a serial stream unless otherwise specified

DerrickSaltFish commented 2 years ago

Mostly the operations whose codes of the order of the execution on the elems of the stream doesn't matter.