Why cant I add my own intermidate operation

Boaz Nahum boaznahum at gmail.com
Sun Mar 3 07:58:41 PST 2013


To repeat the trick with *IntStream* (which in my case is more relevant) I
had to duplicate Streams#concat, replacing each *Spliterator<T>* with *
Spliterator.OfInt
*
Hope it can be changed in the future:
http://mail.openjdk.java.net/pipermail/lambda-dev/2013-February/008163.html


Boaz


On Thu, Feb 28, 2013 at 11:18 PM, Boaz Nahum <boaznahum at gmail.com> wrote:

> Thank.
>
> Indeed TERMINATOR and flatMap(FlatMapper) solve all my problems.
>
> On Thu, Feb 28, 2013 at 5:12 PM, Paul Sandoz <paul.sandoz at oracle.com>wrote:
>
>> 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