SlideShare a Scribd company logo
1 of 55
Download to read offline
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6

                  Groovy
Map/Reduce
Fork/Join
                       with


Agent




DataflowVariable
Dataflows
DataflowQueue



                      @Naoki Rin
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  Twitter @Naoki Rin
Map/Reduce
Fork/Join
                  Hatena id:naokirin

                  Groovy      1
                           Java
Agent                        Groovy

                                      Groovy
DataflowVariable
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                   .
                  .1 GPars

                  2
Map/Reduce
Fork/Join


                   .
                  .3

                  4


Agent
                   .
                  .5

DataflowVariable
Dataflows
                  6
DataflowQueue



                  ..
GPars
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars
Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
GPars
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars
Map/Reduce
Fork/Join
                    Groovy       DSL
                    Groovy1.8



Agent




DataflowVariable
Dataflows
DataflowQueue
GPars
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars
Map/Reduce
Fork/Join
                    Groovy       DSL
                    Groovy1.8



Agent

                  Groovy
DataflowVariable
Dataflows
DataflowQueue
GPars
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars
Map/Reduce
Fork/Join
                    Groovy       DSL
                    Groovy1.8



Agent

                  Groovy
DataflowVariable
Dataflows
DataflowQueue
GPars
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars
Map/Reduce
Fork/Join
                    Groovy       DSL
                    Groovy1.8



Agent

                  Groovy
DataflowVariable
Dataflows
DataflowQueue
GPars
Groovy
   with GPars

  @Naoki Rin




GPars             Groovy 1.8           GPars 0.11
GPars
GPars 6                 Groovy

Map/Reduce
Fork/Join                          Groovy 1.8.2        GPars 0.12
                                    GPars 0.12


                                   Groovy                     gpars-0.11.jar
Agent             gpars-0.12.jar                  OK

                  Groovy 1.8            @Grab          OK
DataflowVariable
Dataflows
DataflowQueue
                                    GPars 0.12
GPars 6
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars

Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
GPars 6
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars

Map/Reduce
Fork/Join




                    Stm
Agent               Groovy CSP

DataflowVariable
Dataflows
DataflowQueue
GPars 6
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars

Map/Reduce
Fork/Join




                    Stm
Agent               Groovy CSP

DataflowVariable
Dataflows
DataflowQueue
GPars 6
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  GPars

Map/Reduce
Fork/Join




                    Stm
Agent               Groovy CSP

DataflowVariable
Dataflows
                                 4
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
                  (Data Parallelism)
GPars
GPars 6




Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
                    (Data Parallelism)
GPars
GPars 6



                                        Go!
Map/Reduce
Fork/Join


                              (               )   Go!




                  Map/Reduce      Go!


Agent
                  Map/Reduce
                  Fork/Join Go!
DataflowVariable
Dataflows
                  Fork/Join
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6


                  Groovy
Map/Reduce
Fork/Join




                  GParsPool -
                  JSR-166y(ParallelArray)   DSL
Agent


                  GParsExecutorsPool -
DataflowVariable   Java Executor
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6



                      import groovyx.gpars.GParsPool
Map/Reduce
Fork/Join         .
                      GParsPool.withPool {
                        assert ([2, 3, 4, 5]==
                         [1, 2, 3, 4].collectParallel {it + 1})
                      }
                                                                                .
Agent

                      withPool
                      collectParallel()                           collect
DataflowVariable
Dataflows
DataflowQueue




                      ..                                                    .
xxxParallel
Groovy
   with GPars

  @Naoki Rin




GPars
                      withPool         xxxParallel()
GPars
GPars 6




Map/Reduce
Fork/Join
                      withPool
                            xxx


                      findAll()     findAllParallel()
                      import groovyx.gpars.GParsPool
Agent

                      GParsPool.withPool {
                        assert ([1, 2, 3, 4 ].findAll{it % 2 == 0}
DataflowVariable
Dataflows                 == [1, 2, 3, 4 ].findAllParallel{it % 2 == 0})
DataflowQueue
                      }

                  .
xxxParallel
Groovy
   with GPars

  @Naoki Rin




GPars
GPars                             GParsPool.withPool
GPars 6




Map/Reduce
Fork/Join
                  anyParallel()                        findParallel()
                  collectParallel()                    foldParallel()
                  countParallel()                      grepParallel()
                  eachParallel()                       groupByParallel()
                  eachWithIndexParallel()              maxParallel()
Agent
                  everyParallel()                      minParallel()
                  findAllParallel()                     splitParallel()
DataflowVariable
Dataflows
DataflowQueue
                  findAnyParallel()                     sumParallel()
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6



                   withPool
Map/Reduce
Fork/Join
                   import groovyx.gpars.GParsPool

                  . GParsPool.withPool(10) {
                       //
                   }

Agent              withPool                                  .
                                                    +1
DataflowVariable
Dataflows
DataflowQueue




                  ..                                     .
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
                      withPool
GPars 6           .
                      import groovyx.gpars.ParallelEnhancer

Map/Reduce
                      def list = [4, 1, 5, 3, 2 ]
Fork/Join             ParallelEnhancer.enhanceInstance(list)
                      assert (list.findParallel {it == 3} == 3)                .


                      Parallel
                      import groovyx.gpars.GParsPool
Agent


                      .GParsPool.withPool{
                       .                                                  .
                          def data = (1..3).makeConcurrent()
DataflowVariable
Dataflows
                          assert( data.collect {it ** 2} == [1, 4, 9] )
DataflowQueue
                      }

                  .
(               )
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join
                   GParsPool.withPool() {
                     Future result = {it * 2}.callAsync(3)
                     assert 6 == result.get()
                  .}

Agent              withPool        callAsync()
                                                                         .
                                                 Future      get()
DataflowVariable
Dataflows
DataflowQueue




                  ..                                                 .
Map/Reduce
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  Map/Reduce

Map/Reduce
Fork/Join               GPars


                  map
                                         /
Agent
                  reduce
                  map                        (
DataflowVariable
Dataflows
                                    )
DataflowQueue
GPars              Map/Reduce
Groovy
   with GPars

  @Naoki Rin




GPars
GPars             GPars         Map/Reduce     Parallel Array
GPars 6




Map/Reduce                                     Parallel Array
Fork/Join
                                                   parallel


                                             Parallel Array
                                             getParallel()      Parallel
Agent
                  Array

DataflowVariable         Parallel Array   Map
Dataflows
DataflowQueue      collection
Map/Reduce
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join         map()       Parallel Array(AbstractPAWrapper)
                  reduce()    T
                  filter()     Parallel Array(AbstractPAWrapper)
                  size()      int
                  sum()       T
Agent             min()       T
                  max()       T
DataflowVariable
                  sort()      Parallel Array(AbstractPAWrapper)
Dataflows
DataflowQueue
                  groupBy()   Map
                  combine()   Map
Map/Reduce
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6                                      Map
                  . GParsPool.withPool {
Map/Reduce
                       println (”Hello World”.parallel
Fork/Join                .map{[it, 1]}
                         .combine(0) { sum, value -> sum + value}
                         .getParallel()
                         .sort{-it.value}
                         .collection)
                   }
Agent
                                                                    .


DataflowVariable
Dataflows
                   [l=3, o=2, H=1, e=1, W=1, =1, d=1, r=1]
DataflowQueue
Fork/Join
Groovy
   with GPars

  @Naoki Rin




GPars             fork
GPars
GPars 6




Map/Reduce
Fork/Join         join
                  fork




Agent




DataflowVariable
Dataflows
DataflowQueue
Fork/Join
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6


                  forkOffChild() -
Map/Reduce
Fork/Join



                  runChildDirectly() -


                  GPars 0.12
Agent
                  getChildrenResults() -
                   fork
DataflowVariable
                  runForkJoin() -
Dataflows
DataflowQueue
                   withPool     Fork/Join
Fork/Join
Groovy
   with GPars

  @Naoki Rin




GPars
GPars              fibonacci
GPars 6
                  . import groovyx.gpars.GParsPool

Map/Reduce         Closure fib = {number ->
                     if (number <= 2) {
Fork/Join


                       return 1
                     }
                     forkOffChild(number - 1)
                     final def result = runChildDirectly(number - 2)
                     return (Integer) getChildrenResults().sum() + result
                   }
Agent


                   GParsPool.withPool {
DataflowVariable
                     assert 55 == GParsPool.runForkJoin(10, fib)
Dataflows
DataflowQueue
                   }                                                        .
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
GPars
Groovy
   with GPars

  @Naoki Rin




GPars
GPars             .
GPars 6               import static groovyx.gpars.actor.Actors.*

                      def console = actor { //
Map/Reduce
Fork/Join               loop {
                          react {msg ->
                            println msg
                          }
                        }
                      }
Agent
                                                                   .
                      console.send ’Hello World!’ //

DataflowVariable
Dataflows
DataflowQueue

                      Hello World
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6

                                       1
                      import static groovyx.gpars.actor.Actors.*
Map/Reduce
Fork/Join         .
                      def console = actor {
                        react {msg ->
                          println msg
                        }
                      }
Agent

                      react                                        .
                                               react
DataflowVariable
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join           console.send ’Hello World!’ //
                    console ’Hello World!’      //
                  . console << ’Hello World!’ //
                    console.call ’Hello World!’ //


Agent                                                    .

DataflowVariable
Dataflows
DataflowQueue


                  ..                                 .
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6



                  . import static groovyx.gpars.actor.Actors.*
Map/Reduce
Fork/Join          def console = actor {
                     loop{
                       react {msg ->
                         println msg
                       }
                     }
Agent
                   }
                                                                         .
                   loop                                          react
DataflowVariable
Dataflows
DataflowQueue
reactor
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
                      reactor
Fork/Join
                      import static groovyx.gpars.actor.Actors.*

                      def console = reactor { //                   }
                  .
                      actor{loop{react{ }}}                            reactor{}
Agent                                                                                  .


DataflowVariable
Dataflows
DataflowQueue
                      ..                                                           .
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join
                    console.send ’Hello!’
                    console.send ’Hello!!’
                  . console.stop()
                    console.join()

                   join()                        .
Agent




DataflowVariable
Dataflows
DataflowQueue
                   ..                        .
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce

                   def console = reactor {reply it.reverse()}
Fork/Join


                   assert ’Hello!’ == console.sendAndWait(’ !olleH’)
                  . reply
                   sendAndWait()                                           .
Agent



                   ..                                                  .
DataflowVariable
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6


                      def parrot = reactor {
                  .
Map/Reduce
                        println ’Parrot: ’ + it
Fork/Join               sender.send it
                      }

                      def mary = actor {
                        println ’Mary: Hello!’
                        parrot.send ’Hello!’
Agent                   react{println ’Mary: Good!’}
                      }
                                                       .
DataflowVariable
Dataflows              sender
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                  (   )

Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
GPars
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6           . import groovyx.gpars.GParsPool
                   import groovyx.gpars.agent.Agent
Map/Reduce
Fork/Join
                   def agent = new Agent(1)
                   GParsPool.withPool {
                     (1..10).eachParallel {value ->
                       agent {updateValue(it * value)}
                     }
                   }
Agent
                   println agent.val                     .

DataflowVariable
Dataflows
DataflowQueue
                   3628800
Agent
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                      Agent
                      import groovyx.gpars.agent.Agent
Map/Reduce
                  .
Fork/Join
                      def intAgent = new Agent(0)
                      def stringAgent = new Agent<String>()
                      assert 0 == intAgent.val
                                                                  .
                      Agent
Agent
                      Groovy

DataflowVariable
Dataflows
                                 .val
DataflowQueue          ..                                      .
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
                  .
GPars 6               import groovyx.gpars.agent.Agent

                      def jvmLangList = new Agent<List<String>>()
Map/Reduce
Fork/Join
                      jvmLangList {updateValue([’Java’])}
                      jvmLangList.send {it << ’Scala’}
                      jvmLangList.call {it.add ’Clojure’}
                      jvmLangList jvmLangList.val + ’Groovy’
                      assert [’Java’, ’Scala’, ’Clojure’, ’Groovy’]
                                                                      .
                        == jvmLangList.val
Agent



                      updateValue()
DataflowVariable
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin


                  .
GPars
GPars                 def members = new Agent([’Jones’])
GPars 6
                      final Thread t1 = Thread.start {
                        members {it.add ’Bob’}
Map/Reduce              members {it.add ’Davis’}
Fork/Join
                      }
                      final Thread t2 = Thread.start {
                        members {it.add ’Alice’}
                        members {it.remove(0)}
                      }
Agent
                      //        [Jones, Bob, Davis, Alice]       .
                      members.valAsync {println it}

DataflowVariable       .val
Dataflows
DataflowQueue

                      valAsync()                    valAsync()
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
(   )
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue
GPars               Dataflow
Groovy
   with GPars

  @Naoki Rin




GPars
                  .
GPars
GPars 6
                      import groovyx.gpars.dataflow.Dataflow
                      import groovyx.gpars.dataflow.DataflowVariable

Map/Reduce            final def x = new DataflowVariable()
Fork/Join
                      final def y = new DataflowVariable()
                      final def z = new DataflowVariable()

                      Dataflow.task { z << x.val + y.val }
                      Dataflow.task { x << 5 }
                      Dataflow.task { y << 10 }
Agent
                                                                     .
                      println z.val
DataflowVariable
Dataflows
DataflowQueue


                      15
DataflowVariable
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
                  . DataflowVariable
GPars 6           import static groovyx.gpars.dataflow.Dataflow.task
                  import groovyx.gpars.dataflow.DataflowVariable

Map/Reduce
Fork/Join
                  final def x = new DataflowVariable()
                  final def y = new DataflowVariable()

                  task{y << x.val + 1}
                  task{x << 1}
                                                                     .
Agent             assert 2 == y.val

                  DataflowVariable
DataflowVariable
Dataflows
DataflowQueue
                  Dataflow.task
                  task
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6

                  . import static groovyx.gpars.dataflow.Dataflow.task
                   import groovyx.gpars.dataflow.DataflowVariable
Map/Reduce
Fork/Join
                   def x = new DataflowVariable()
                   def y = new DataflowVariable()

                   task {x << y.val}
                   task {y << x.val}
Agent
                   println x.val //            !                       .
DataflowVariable
Dataflows
DataflowQueue
Dataflows
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
                      Dataflows
GPars 6           .
                      import static groovyx.gpars.dataflow.Dataflow.task
                      import groovyx.gpars.dataflow.Dataflows
Map/Reduce
Fork/Join             final def dfs = new Dataflows()
                      task {dfs[0] = dfs.x + ” ” + dfs.y}
                      task {dfs.y = ”Groovy!”}
                      task {dfs.x = ”Hello”}

                      assert ”Hello Groovy!” == dfs[0]                   .
Agent

                      Dataflows      DataflowVariable
DataflowVariable
Dataflows
DataflowQueue
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6
                   DatafowQueue
                  . import groovyx.gpars.dataflow.DataflowQueue
Map/Reduce
Fork/Join
                   final def queue = new DataflowQueue()
                   queue << ’a’
                   queue << ’b’
                   queue << ’c’

                   assert ’a’ == queue.val
Agent
                   assert ’b’ == queue.val
                   assert ’c’ == queue.val                      .
DataflowVariable    DataflowQueue
Dataflows
DataflowQueue                                  .val
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join
                  GPars   Groovy


Agent




DataflowVariable
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join

                                                Groovy
                      http://gihyo.jp/book/2011/978-4-7741-4727-7


                  GPars Users Guide
                      http://gpars.org/0.12/guide/index.html
Agent


                  GPars Javadoc
DataflowVariable       http://gpars.org/0.12/javadoc
Dataflows
DataflowQueue
Groovy
   with GPars

  @Naoki Rin




GPars
GPars
GPars 6




Map/Reduce
Fork/Join




Agent




DataflowVariable
Dataflows
DataflowQueue

More Related Content

What's hot

Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Grant McAlister
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingHenry Schreiner
 
05 Analysis of Algorithms: Heap and Quick Sort - Corrected
05 Analysis of Algorithms: Heap and Quick Sort - Corrected05 Analysis of Algorithms: Heap and Quick Sort - Corrected
05 Analysis of Algorithms: Heap and Quick Sort - CorrectedAndres Mendez-Vazquez
 
Qtp Training Deepti 4 Of 4493
Qtp Training Deepti 4 Of 4493Qtp Training Deepti 4 Of 4493
Qtp Training Deepti 4 Of 4493Azhar Satti
 
TriHUG November Pig Talk by Alan Gates
TriHUG November Pig Talk by Alan GatesTriHUG November Pig Talk by Alan Gates
TriHUG November Pig Talk by Alan Gatestrihug
 
An Overview of Hadoop
An Overview of HadoopAn Overview of Hadoop
An Overview of HadoopAsif Ali
 
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록Jaehyeuk Oh
 
Extending Python, what is the best option for me?
Extending Python, what is the best option for me?Extending Python, what is the best option for me?
Extending Python, what is the best option for me?Codemotion
 
RDM 2020: Python, Numpy, and Pandas
RDM 2020: Python, Numpy, and PandasRDM 2020: Python, Numpy, and Pandas
RDM 2020: Python, Numpy, and PandasHenry Schreiner
 
Heaps
HeapsHeaps
HeapsIIUM
 
PEARC17: Modernizing GooFit: A Case Study
PEARC17: Modernizing GooFit: A Case StudyPEARC17: Modernizing GooFit: A Case Study
PEARC17: Modernizing GooFit: A Case StudyHenry Schreiner
 
PyHEP 2019: Python Histogramming Packages
PyHEP 2019: Python Histogramming PackagesPyHEP 2019: Python Histogramming Packages
PyHEP 2019: Python Histogramming PackagesHenry Schreiner
 
Upgrading To The New Map Reduce API
Upgrading To The New Map Reduce APIUpgrading To The New Map Reduce API
Upgrading To The New Map Reduce APITom Croucher
 
ROOT 2018: iminuit and MINUIT2 Standalone
ROOT 2018: iminuit and MINUIT2 StandaloneROOT 2018: iminuit and MINUIT2 Standalone
ROOT 2018: iminuit and MINUIT2 StandaloneHenry Schreiner
 
mruby-rr: Time Traveling Debugger For mruby Using rr
mruby-rr: Time Traveling Debugger For mruby Using rrmruby-rr: Time Traveling Debugger For mruby Using rr
mruby-rr: Time Traveling Debugger For mruby Using rr鈺翔 林
 
確率的プログラミングライブラリEdward
確率的プログラミングライブラリEdward確率的プログラミングライブラリEdward
確率的プログラミングライブラリEdwardYuta Kashino
 

What's hot (20)

Pyspark
PysparkPyspark
Pyspark
 
Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput
 
CMake best practices
CMake best practicesCMake best practices
CMake best practices
 
Digital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meetingDigital RSE: automated code quality checks - RSE group meeting
Digital RSE: automated code quality checks - RSE group meeting
 
ACAT 2017: GooFit 2.0
ACAT 2017: GooFit 2.0ACAT 2017: GooFit 2.0
ACAT 2017: GooFit 2.0
 
05 Analysis of Algorithms: Heap and Quick Sort - Corrected
05 Analysis of Algorithms: Heap and Quick Sort - Corrected05 Analysis of Algorithms: Heap and Quick Sort - Corrected
05 Analysis of Algorithms: Heap and Quick Sort - Corrected
 
Qtp Training Deepti 4 Of 4493
Qtp Training Deepti 4 Of 4493Qtp Training Deepti 4 Of 4493
Qtp Training Deepti 4 Of 4493
 
TriHUG November Pig Talk by Alan Gates
TriHUG November Pig Talk by Alan GatesTriHUG November Pig Talk by Alan Gates
TriHUG November Pig Talk by Alan Gates
 
An Overview of Hadoop
An Overview of HadoopAn Overview of Hadoop
An Overview of Hadoop
 
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록
 
Extending Python, what is the best option for me?
Extending Python, what is the best option for me?Extending Python, what is the best option for me?
Extending Python, what is the best option for me?
 
RDM 2020: Python, Numpy, and Pandas
RDM 2020: Python, Numpy, and PandasRDM 2020: Python, Numpy, and Pandas
RDM 2020: Python, Numpy, and Pandas
 
Heaps
HeapsHeaps
Heaps
 
PEARC17: Modernizing GooFit: A Case Study
PEARC17: Modernizing GooFit: A Case StudyPEARC17: Modernizing GooFit: A Case Study
PEARC17: Modernizing GooFit: A Case Study
 
PyHEP 2019: Python Histogramming Packages
PyHEP 2019: Python Histogramming PackagesPyHEP 2019: Python Histogramming Packages
PyHEP 2019: Python Histogramming Packages
 
Upgrading To The New Map Reduce API
Upgrading To The New Map Reduce APIUpgrading To The New Map Reduce API
Upgrading To The New Map Reduce API
 
ROOT 2018: iminuit and MINUIT2 Standalone
ROOT 2018: iminuit and MINUIT2 StandaloneROOT 2018: iminuit and MINUIT2 Standalone
ROOT 2018: iminuit and MINUIT2 Standalone
 
PyHEP 2019: Python 3.8
PyHEP 2019: Python 3.8PyHEP 2019: Python 3.8
PyHEP 2019: Python 3.8
 
mruby-rr: Time Traveling Debugger For mruby Using rr
mruby-rr: Time Traveling Debugger For mruby Using rrmruby-rr: Time Traveling Debugger For mruby Using rr
mruby-rr: Time Traveling Debugger For mruby Using rr
 
確率的プログラミングライブラリEdward
確率的プログラミングライブラリEdward確率的プログラミングライブラリEdward
確率的プログラミングライブラリEdward
 

Recently uploaded

Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 

Recently uploaded (20)

Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 

GPars in Saga Groovy Study

  • 1. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Groovy Map/Reduce Fork/Join with Agent DataflowVariable Dataflows DataflowQueue @Naoki Rin
  • 2. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Twitter @Naoki Rin Map/Reduce Fork/Join Hatena id:naokirin Groovy 1 Java Agent Groovy Groovy DataflowVariable Dataflows DataflowQueue
  • 3. Groovy with GPars @Naoki Rin GPars GPars GPars 6 . .1 GPars 2 Map/Reduce Fork/Join . .3 4 Agent . .5 DataflowVariable Dataflows 6 DataflowQueue ..
  • 4. GPars Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 5. GPars Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Groovy DSL Groovy1.8 Agent DataflowVariable Dataflows DataflowQueue
  • 6. GPars Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Groovy DSL Groovy1.8 Agent Groovy DataflowVariable Dataflows DataflowQueue
  • 7. GPars Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Groovy DSL Groovy1.8 Agent Groovy DataflowVariable Dataflows DataflowQueue
  • 8. GPars Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Groovy DSL Groovy1.8 Agent Groovy DataflowVariable Dataflows DataflowQueue
  • 9. GPars Groovy with GPars @Naoki Rin GPars Groovy 1.8 GPars 0.11 GPars GPars 6 Groovy Map/Reduce Fork/Join Groovy 1.8.2 GPars 0.12 GPars 0.12 Groovy gpars-0.11.jar Agent gpars-0.12.jar OK Groovy 1.8 @Grab OK DataflowVariable Dataflows DataflowQueue GPars 0.12
  • 10. GPars 6 Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 11. GPars 6 Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Stm Agent Groovy CSP DataflowVariable Dataflows DataflowQueue
  • 12. GPars 6 Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Stm Agent Groovy CSP DataflowVariable Dataflows DataflowQueue
  • 13. GPars 6 Groovy with GPars @Naoki Rin GPars GPars GPars 6 GPars Map/Reduce Fork/Join Stm Agent Groovy CSP DataflowVariable Dataflows 4 DataflowQueue
  • 14. Groovy with GPars @Naoki Rin GPars (Data Parallelism) GPars GPars 6 Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 15. Groovy with GPars @Naoki Rin GPars (Data Parallelism) GPars GPars 6 Go! Map/Reduce Fork/Join ( ) Go! Map/Reduce Go! Agent Map/Reduce Fork/Join Go! DataflowVariable Dataflows Fork/Join DataflowQueue
  • 16. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Groovy Map/Reduce Fork/Join GParsPool - JSR-166y(ParallelArray) DSL Agent GParsExecutorsPool - DataflowVariable Java Executor Dataflows DataflowQueue
  • 17. Groovy with GPars @Naoki Rin GPars GPars GPars 6 import groovyx.gpars.GParsPool Map/Reduce Fork/Join . GParsPool.withPool { assert ([2, 3, 4, 5]== [1, 2, 3, 4].collectParallel {it + 1}) } . Agent withPool collectParallel() collect DataflowVariable Dataflows DataflowQueue .. .
  • 18. xxxParallel Groovy with GPars @Naoki Rin GPars withPool xxxParallel() GPars GPars 6 Map/Reduce Fork/Join withPool xxx findAll() findAllParallel() import groovyx.gpars.GParsPool Agent GParsPool.withPool { assert ([1, 2, 3, 4 ].findAll{it % 2 == 0} DataflowVariable Dataflows == [1, 2, 3, 4 ].findAllParallel{it % 2 == 0}) DataflowQueue } .
  • 19. xxxParallel Groovy with GPars @Naoki Rin GPars GPars GParsPool.withPool GPars 6 Map/Reduce Fork/Join anyParallel() findParallel() collectParallel() foldParallel() countParallel() grepParallel() eachParallel() groupByParallel() eachWithIndexParallel() maxParallel() Agent everyParallel() minParallel() findAllParallel() splitParallel() DataflowVariable Dataflows DataflowQueue findAnyParallel() sumParallel()
  • 20. Groovy with GPars @Naoki Rin GPars GPars GPars 6 withPool Map/Reduce Fork/Join import groovyx.gpars.GParsPool . GParsPool.withPool(10) { // } Agent withPool . +1 DataflowVariable Dataflows DataflowQueue .. .
  • 21. Groovy with GPars @Naoki Rin GPars GPars withPool GPars 6 . import groovyx.gpars.ParallelEnhancer Map/Reduce def list = [4, 1, 5, 3, 2 ] Fork/Join ParallelEnhancer.enhanceInstance(list) assert (list.findParallel {it == 3} == 3) . Parallel import groovyx.gpars.GParsPool Agent .GParsPool.withPool{ . . def data = (1..3).makeConcurrent() DataflowVariable Dataflows assert( data.collect {it ** 2} == [1, 4, 9] ) DataflowQueue } .
  • 22. ( ) Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join GParsPool.withPool() { Future result = {it * 2}.callAsync(3) assert 6 == result.get() .} Agent withPool callAsync() . Future get() DataflowVariable Dataflows DataflowQueue .. .
  • 23. Map/Reduce Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Map/Reduce Fork/Join GPars map / Agent reduce map ( DataflowVariable Dataflows ) DataflowQueue
  • 24. GPars Map/Reduce Groovy with GPars @Naoki Rin GPars GPars GPars Map/Reduce Parallel Array GPars 6 Map/Reduce Parallel Array Fork/Join parallel Parallel Array getParallel() Parallel Agent Array DataflowVariable Parallel Array Map Dataflows DataflowQueue collection
  • 25. Map/Reduce Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join map() Parallel Array(AbstractPAWrapper) reduce() T filter() Parallel Array(AbstractPAWrapper) size() int sum() T Agent min() T max() T DataflowVariable sort() Parallel Array(AbstractPAWrapper) Dataflows DataflowQueue groupBy() Map combine() Map
  • 26. Map/Reduce Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map . GParsPool.withPool { Map/Reduce println (”Hello World”.parallel Fork/Join .map{[it, 1]} .combine(0) { sum, value -> sum + value} .getParallel() .sort{-it.value} .collection) } Agent . DataflowVariable Dataflows [l=3, o=2, H=1, e=1, W=1, =1, d=1, r=1] DataflowQueue
  • 27. Fork/Join Groovy with GPars @Naoki Rin GPars fork GPars GPars 6 Map/Reduce Fork/Join join fork Agent DataflowVariable Dataflows DataflowQueue
  • 28. Fork/Join Groovy with GPars @Naoki Rin GPars GPars GPars 6 forkOffChild() - Map/Reduce Fork/Join runChildDirectly() - GPars 0.12 Agent getChildrenResults() - fork DataflowVariable runForkJoin() - Dataflows DataflowQueue withPool Fork/Join
  • 29. Fork/Join Groovy with GPars @Naoki Rin GPars GPars fibonacci GPars 6 . import groovyx.gpars.GParsPool Map/Reduce Closure fib = {number -> if (number <= 2) { Fork/Join return 1 } forkOffChild(number - 1) final def result = runChildDirectly(number - 2) return (Integer) getChildrenResults().sum() + result } Agent GParsPool.withPool { DataflowVariable assert 55 == GParsPool.runForkJoin(10, fib) Dataflows DataflowQueue } .
  • 30. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 31. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 32. GPars Groovy with GPars @Naoki Rin GPars GPars . GPars 6 import static groovyx.gpars.actor.Actors.* def console = actor { // Map/Reduce Fork/Join loop { react {msg -> println msg } } } Agent . console.send ’Hello World!’ // DataflowVariable Dataflows DataflowQueue Hello World
  • 33. Groovy with GPars @Naoki Rin GPars GPars GPars 6 1 import static groovyx.gpars.actor.Actors.* Map/Reduce Fork/Join . def console = actor { react {msg -> println msg } } Agent react . react DataflowVariable Dataflows DataflowQueue
  • 34. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join console.send ’Hello World!’ // console ’Hello World!’ // . console << ’Hello World!’ // console.call ’Hello World!’ // Agent . DataflowVariable Dataflows DataflowQueue .. .
  • 35. Groovy with GPars @Naoki Rin GPars GPars GPars 6 . import static groovyx.gpars.actor.Actors.* Map/Reduce Fork/Join def console = actor { loop{ react {msg -> println msg } } Agent } . loop react DataflowVariable Dataflows DataflowQueue
  • 36. reactor Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce reactor Fork/Join import static groovyx.gpars.actor.Actors.* def console = reactor { // } . actor{loop{react{ }}} reactor{} Agent . DataflowVariable Dataflows DataflowQueue .. .
  • 37. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join console.send ’Hello!’ console.send ’Hello!!’ . console.stop() console.join() join() . Agent DataflowVariable Dataflows DataflowQueue .. .
  • 38. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce def console = reactor {reply it.reverse()} Fork/Join assert ’Hello!’ == console.sendAndWait(’ !olleH’) . reply sendAndWait() . Agent .. . DataflowVariable Dataflows DataflowQueue
  • 39. Groovy with GPars @Naoki Rin GPars GPars GPars 6 def parrot = reactor { . Map/Reduce println ’Parrot: ’ + it Fork/Join sender.send it } def mary = actor { println ’Mary: Hello!’ parrot.send ’Hello!’ Agent react{println ’Mary: Good!’} } . DataflowVariable Dataflows sender DataflowQueue
  • 40. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 41. Groovy with GPars @Naoki Rin GPars GPars GPars 6 ( ) Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 42. GPars Groovy with GPars @Naoki Rin GPars GPars GPars 6 . import groovyx.gpars.GParsPool import groovyx.gpars.agent.Agent Map/Reduce Fork/Join def agent = new Agent(1) GParsPool.withPool { (1..10).eachParallel {value -> agent {updateValue(it * value)} } } Agent println agent.val . DataflowVariable Dataflows DataflowQueue 3628800
  • 43. Agent Groovy with GPars @Naoki Rin GPars GPars GPars 6 Agent import groovyx.gpars.agent.Agent Map/Reduce . Fork/Join def intAgent = new Agent(0) def stringAgent = new Agent<String>() assert 0 == intAgent.val . Agent Agent Groovy DataflowVariable Dataflows .val DataflowQueue .. .
  • 44. Groovy with GPars @Naoki Rin GPars GPars . GPars 6 import groovyx.gpars.agent.Agent def jvmLangList = new Agent<List<String>>() Map/Reduce Fork/Join jvmLangList {updateValue([’Java’])} jvmLangList.send {it << ’Scala’} jvmLangList.call {it.add ’Clojure’} jvmLangList jvmLangList.val + ’Groovy’ assert [’Java’, ’Scala’, ’Clojure’, ’Groovy’] . == jvmLangList.val Agent updateValue() DataflowVariable Dataflows DataflowQueue
  • 45. Groovy with GPars @Naoki Rin . GPars GPars def members = new Agent([’Jones’]) GPars 6 final Thread t1 = Thread.start { members {it.add ’Bob’} Map/Reduce members {it.add ’Davis’} Fork/Join } final Thread t2 = Thread.start { members {it.add ’Alice’} members {it.remove(0)} } Agent // [Jones, Bob, Davis, Alice] . members.valAsync {println it} DataflowVariable .val Dataflows DataflowQueue valAsync() valAsync()
  • 46. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 47. ( ) Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue
  • 48. GPars Dataflow Groovy with GPars @Naoki Rin GPars . GPars GPars 6 import groovyx.gpars.dataflow.Dataflow import groovyx.gpars.dataflow.DataflowVariable Map/Reduce final def x = new DataflowVariable() Fork/Join final def y = new DataflowVariable() final def z = new DataflowVariable() Dataflow.task { z << x.val + y.val } Dataflow.task { x << 5 } Dataflow.task { y << 10 } Agent . println z.val DataflowVariable Dataflows DataflowQueue 15
  • 49. DataflowVariable Groovy with GPars @Naoki Rin GPars GPars . DataflowVariable GPars 6 import static groovyx.gpars.dataflow.Dataflow.task import groovyx.gpars.dataflow.DataflowVariable Map/Reduce Fork/Join final def x = new DataflowVariable() final def y = new DataflowVariable() task{y << x.val + 1} task{x << 1} . Agent assert 2 == y.val DataflowVariable DataflowVariable Dataflows DataflowQueue Dataflow.task task
  • 50. Groovy with GPars @Naoki Rin GPars GPars GPars 6 . import static groovyx.gpars.dataflow.Dataflow.task import groovyx.gpars.dataflow.DataflowVariable Map/Reduce Fork/Join def x = new DataflowVariable() def y = new DataflowVariable() task {x << y.val} task {y << x.val} Agent println x.val // ! . DataflowVariable Dataflows DataflowQueue
  • 51. Dataflows Groovy with GPars @Naoki Rin GPars GPars Dataflows GPars 6 . import static groovyx.gpars.dataflow.Dataflow.task import groovyx.gpars.dataflow.Dataflows Map/Reduce Fork/Join final def dfs = new Dataflows() task {dfs[0] = dfs.x + ” ” + dfs.y} task {dfs.y = ”Groovy!”} task {dfs.x = ”Hello”} assert ”Hello Groovy!” == dfs[0] . Agent Dataflows DataflowVariable DataflowVariable Dataflows DataflowQueue
  • 52. DataflowQueue Groovy with GPars @Naoki Rin GPars GPars GPars 6 DatafowQueue . import groovyx.gpars.dataflow.DataflowQueue Map/Reduce Fork/Join final def queue = new DataflowQueue() queue << ’a’ queue << ’b’ queue << ’c’ assert ’a’ == queue.val Agent assert ’b’ == queue.val assert ’c’ == queue.val . DataflowVariable DataflowQueue Dataflows DataflowQueue .val
  • 53. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join GPars Groovy Agent DataflowVariable Dataflows DataflowQueue
  • 54. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join Groovy http://gihyo.jp/book/2011/978-4-7741-4727-7 GPars Users Guide http://gpars.org/0.12/guide/index.html Agent GPars Javadoc DataflowVariable http://gpars.org/0.12/javadoc Dataflows DataflowQueue
  • 55. Groovy with GPars @Naoki Rin GPars GPars GPars 6 Map/Reduce Fork/Join Agent DataflowVariable Dataflows DataflowQueue