2

Definition of fold from Play! API is

enter image description here

as the folding function takes two different types A , E does this mean this operation is not run in parallel ?

As according to Fold and foldLeft method difference the type signature of fold (from Scala API) :

enter image description here

the op function takes two of same types (A1), this allows the operation to be run in parallel.

The fold operation itself is implemented in a new thread using ExecutionContext which is passed as an implicit. The fold type signature suggests it cannot be implemented in parallel, Iteratee.fold creates a new thread for the fold operation and therefore is non blocking. In summary fold is not a parallel operation but is non-blocking ? This is in contrast to Scala fold operation which can be run in parallel.

Community
  • 1
  • 1
blue-sky
  • 51,962
  • 152
  • 427
  • 752
  • I assume that the mere fact that an aggregator is used prohibits any parallel execution. How would multiple aggregators resulting from partial processing be combined? – devkat May 27 '16 at 15:15
  • @Andreas Jim-Hartmann 'How would multiple aggregators resulting from partial processing be combined?' I don't know but any such combination would need to be associative I assume. It's probably safe to say that fold fomr Play! API is essentially the same as a foldLeft operation from Scala API ? – blue-sky May 27 '16 at 15:19
  • From the documentation this seems to be the case. The fold1 method seems to support asynchronous processing (see https://www.playframework.com/documentation/2.6.x/Iteratees). – devkat May 29 '16 at 15:05

0 Answers0