SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

Dernier

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Dernier (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

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