How are streams like Java's Stream API or RxJava represented on the assembly level?
I.E.
List<String> myList =
Arrays.asList("a1", "a2", "b1", "c2", "c1");
myList
.stream()
.filter(s -> s.startsWith("c"))
.map(String::toUpperCase)
.sorted()
.forEach(System.out::println);
It's a very complex topic to cover in a few sentences. You can start researching from this article by Brian Goetz to understand concept of Java Stream API. After that you'll be able to easily go deeper.
First of all take a closer look at Spliterator abstraction:
A stream source is described by an abstraction called Spliterator. As its name suggests, Spliterator combines two behaviors: accessing the elements of the source (iterating), and possibly decomposing the input source for parallel execution (splitting).
Then take a look at Stream flags :
In the internal representation, each stage of the pipeline is described by a bitmap of stream flags that describe what’s known about the elements at this stage of the stream pipeline. Streams uses these flags to optimize both the construction and execution of the stream.
and execution of Stream pipeline
When the terminal operation is initiated, the stream implementation picks an execution plan.
For sequential execution, Streams constructs a “machine” — a chain of Consumer objects whose structure matches that of the pipeline structure. Each of these Consumer objects knows about the next stage; when it receives an element (or is notified that there are no more elements), it sends zero or more elements to the next stage in the chain.
And then you'll be able to find out how each of intermediate and terminal operations represented at assemble level.