Why cant I add my own intermidate operation
Paul Sandoz
paul.sandoz at oracle.com
Thu Feb 28 07:12:40 PST 2013
Hi Boaz,
Unfortunately the internals are not ready to open as an SPI, more time is required to do that, time that we don't have for JDK 8. What is there now could well change in the future and we don't want to be stuck with it.
That tiny 'gate' you are referring while tiny from a method on Stream perspective is far from tiny otherwise as it opens up access to other internal classes, such as Sink and Node, and opens up concepts of stream flags, sequential and parallel implementations.
On Feb 27, 2013, at 4:10 PM, Boaz Nahum <boaznahum at gmail.com> wrote:
> Many and I asked before how can I do that and that (for example producing
> stream of parser tokens from stream, that cant be done by #collect, because
> we have no way to know where the input stream is ended)
>
As a workaround you can concatenate:
Streams.concat(s, Collections.singletonList(TERMINATOR).stream());
If you look at the code for that it uses the "escape-hatch" spliterator. There might be similar tricks you can apply.
Paul.
> I understand that not any wish can be satisfied.
>
> But why not provide a tiny 'gate' to add my pipeline, something like
> already done:
>
> public <E_NEXT, S_NEXT extends BaseStream<E_NEXT, S_NEXT>> S_NEXT
> pipeline(IntermediateOp<E_OUT, E_NEXT> newOp) {
>
> That all I need(I know I can do there many mistakes, write it
> inefficient,but still it is better than nothing).
>
> Today I need to break the pipeline (at least syntactically)
>
> My feeling is that 'Stream' is so difficult to extend. Why *so many
> interfaces such as IntermediateOp* and TerminalOp are not public ?
>
> Thanks
> Boaz
>
More information about the lambda-dev
mailing list