gpars map reducer example

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

gpars map reducer example

yiguang hu
I am playing the groovy map reducer example. What/how should I setup to make it work? (I am using groovy 1.7.1).


@Grab(group='org.codehaus.gpars', module='gpars', version='0.9')
def myNumbers = (1..1000).parallel.filter{it % 2 == 0}.map{Math.sqrt it}.collection


When I run the above code, it complains the following:

Caught: groovy.lang.MissingPropertyException: Exception evaluating property 'parallel' for groovy.lang.IntRange, Reason: groovy.lang.MissingPropertyException: No such property: parallel for class: java.lang.Integer
        at mapreduce.run(mapreduce.groovy:2)

Thanks
Yiguang


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: gpars map reducer example

Paul King
On 15/03/2010 12:08 PM, Yiguang Hu wrote:
> @Grab(group='org.codehaus.gpars', module='gpars', version='0.9')
> def myNumbers = (1..1000).parallel.filter{it % 2 == 0}.map{Math.sqrt it}.collection

You have a number of ways you could do that. Here are two:

@Grab(group='org.codehaus.gpars', module='gpars', version='0.9')
import static groovyx.gpars.Parallelizer.*
doParallel {
   def myNumbers = (1..1000).parallel.filter{it % 2 == 0}.map{Math.sqrt it}.collection
   println myNumbers
}

@Grab(group='org.codehaus.gpars', module='gpars', version='0.9')
import static groovyx.gpars.ParallelEnhancer.*
enhanceClass IntRange
def myNumbers = (1..1000).findAllParallel{it % 2 == 0}.collectParallel{Math.sqrt it}
println myNumbers


Cheers, Paul.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: gpars map reducer example

yiguang hu
Thanks a lot for the help. It works now.

On Sun, Mar 14, 2010 at 11:13 PM, Paul King <[hidden email]> wrote:
On 15/03/2010 12:08 PM, Yiguang Hu wrote:
@Grab(group='org.codehaus.gpars', module='gpars', version='0.9')
def myNumbers = (1..1000).parallel.filter{it % 2 == 0}.map{Math.sqrt it}.collection

You have a number of ways you could do that. Here are two:


@Grab(group='org.codehaus.gpars', module='gpars', version='0.9')
import static groovyx.gpars.Parallelizer.*
doParallel {

 def myNumbers = (1..1000).parallel.filter{it % 2 == 0}.map{Math.sqrt it}.collection
 println myNumbers

}

@Grab(group='org.codehaus.gpars', module='gpars', version='0.9')
import static groovyx.gpars.ParallelEnhancer.*
enhanceClass IntRange
def myNumbers = (1..1000).findAllParallel{it % 2 == 0}.collectParallel{Math.sqrt it}
println myNumbers


Cheers, Paul.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email