Basic functional style question

mohan.radhakrishnan at polarisFT.com mohan.radhakrishnan at polarisFT.com
Wed Nov 27 04:08:44 PST 2013


Not a fork. I used to filter 'Full GC' lines and then apply a pattern to 
filter the times and then get the sizes of memory pools. How is this done 
if I have several regex patterns ?
The pipeline could be long.

I have seen that array initializers use lambdas. So I thought that an 
array/ArrayList of values can be filtered in-place by applying a function 
assuming no concurrency is required. 


Thanks. 
Mohan



From:   Paul Sandoz <paul.sandoz at oracle.com>
To: 
Cc:     lambda-dev at openjdk.java.net
Date:   11/27/2013 05:03 PM
Subject:        Re: Basic functional style question
Sent by:        lambda-dev-bounces at openjdk.java.net




On Nov 27, 2013, at 11:47 AM, mohan.radhakrishnan at polarisft.com wrote:

> Yes. Thanks Stuart. 
> 
> I also have these questions.
> 
> 1. How do I apply a large number of regex patterns one by one in the 
same 
> pipeline ? When is a new functional interface needed ?
> 

Do you want to fork the stream of lines into N separate stream of lines 
each mapping/filtering using a separate regex?


> 2.  function(){
>        return (data$V1[ grep ("(.*)Full GC(.*)", data[,1])])
>     }
> 
>     Is there a way to do this ? This R code uses code to change values 
in 
> a data structure in-place. Code and data are together here.
> 

Structural modifications to the source should not be made during executing 
of the pipeline, otherwise it will lead to either a 
ConcurrentModificationException or undefined results. 

In place modifications, like the above, might be possible depending on the 
source, such as an array, but you really need to be careful and know what 
you are doing e.g. using a forEach with side-effects such that those 
side-effects are safe under concurrent operation. 

Trying to do this in anything other than forEach is asking for trouble and 
going against the rules that function values passed to operations should 
be stateless and not have side-effects (or more specifically side-effects 
that may effect results, but in general it is best to try and always avoid 
side-effects).

Hth,
Paul.





This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only.  If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com


More information about the lambda-dev mailing list