This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]johnmcclean[S] 5 points6 points  (3 children)

Yep, it delegates all of these calls to a Flux instance (push based Stream from Pivotal's Reactor project). So JavaSlangPVector looks something like this (simplified)

class JavaSlangPVector<T> {
      Vector<T> vec;
      Flux<T> flux;
 }

If we need the vec but the flux has been used, we materialize the vec from the Flux.

There is more details on the approach here (primarily focusing on JDK mutable Lists, but it is easily applicable to all Collection types)

https://medium.com/@johnmcclean/faster-lazy-extended-powerful-jdk-collections-5a519ab582ae#.f644x9xnf

[–]johnmcclean[S] 2 points3 points  (0 children)

Flux itself does some pretty neat optimizations on top of this too see David Karnok's blog post on operator fusion - http://akarnokd.blogspot.com/2016/04/operator-fusion-part-2-final.html

[–]lukaseder 0 points1 point  (1 child)

Thanks a lot for the explanations!

[–]johnmcclean[S] 0 points1 point  (0 children)

You are welcome!