Pipeline: the whole operation, from source to terminal operation
What features do we need?
consume: produce ratios (1:1, 1:N, N:1, N:M)
finite or infinite
infinite requires incremental operation
finite benefits from incremental operation
stateful or stateless
some operations are inherently stateless / stateful
frugal or greedy
frugal requires incremental operation
greedy benefits from incremental operation
sequential or parallellizable
some operations are trivially parallelizable
some operations can only run sequentially
finishing touches or not
some operations can only work when they know that there are no more input elements
Stream.gather(Gatherer): an extensible API for intermediate operations:
interfae Gathere<T, A, R> { // Provides the state, if any, to be used during evaluation of the gatherer. Supplier<A> initializer(); // Each inputelement is applied to the integrator, together with the state, and a Downstream handle for as long as it returns `true`. Integrator<A, T, R> integrator(); // If it returns anything but the default value, this Gatherer can be parallelized. // When parallellized, this is used to merge partial results into one. BinaryOperator<A> combiner(); // When there are no more input elements, this function is invoked with the state and a Downstream handle to perform a final action. BiConsumer<A, Downstream<R>> finisher();}