Skip operation

Arul Dhesiaseelan aruld at acm.org
Tue Sep 18 10:34:38 PDT 2012


Is there a plan to support skipWhile and takeWhile operations on the
stream, for example, loading orders from a csv dump that has markers for
orders?

skipWhile(line -> line.startsWith("ORDERS BEGIN"))
.skip(1)
.takeWhile(line -> line.startsWith("ORDERS END")
.transform(line -> new Order(line))
.into(new ArrayList<Order>);

-Arul

On Tue, Sep 18, 2012 at 6:21 AM, Henry Jen <henry.jen at oracle.com> wrote:

>
> On Sep 18, 2012, at 3:01 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
> > Hi Henry,
> >
> > On Sep 17, 2012, at 5:31 PM, Henry Jen <henry.jen at oracle.com> wrote:
> >
> >> The patch looks good.
> >>
> >> At beginning I thought it to be a 'step' operation, then realize it's a
> one-time skip operation.
> >>
> >> Does it make sense to have a step operation as well?
> >
> > Can you give an example?
> >
>
> countTo(10).step(1).sum() would be a sum of odd numbers.
>
> Useful when doing sampling.
>
> >
> >> Both skip and serial probably be serial only.
> >>
> >
> > It might be possible to implement limit/skip in parallel, although i
> admit to not currently knowing how :-)n , need to experiment. probably
> requires some way to cancel the creation of new F/J tasks and ones that are
> running.
>
> Agree. Without a predictable split, it would be challenging to step in
> parallel. :)
>
> Cheers,
> Henry
>
>
>


More information about the lambda-dev mailing list