[concurrency-interest] ParallelArray Extension

Kasper Nielsen kasper at kav.dk
Wed Dec 19 12:31:22 EST 2007


Tim Peierls wrote:
> On Dec 19, 2007 10:13 AM, Kasper Nielsen <kasper at kav.dk 
> <mailto:kasper at kav.dk>> wrote:
> 
>     Tim Peierls wrote:
>      > These sound like applications for map-reduce:
>      >
>      > 1. w.withMapping(elementsToSingletonSets).reduce(combineSets);
>      > 2. w.withMapping(elementsToAggregates).reduce(combineAggregates);
>      >
>      > I'm don't know whether these will perform as well in practice as the
>      > solutions you've come up with, but they seem essentially
>     equivalent to
>      > your proposed combineReduce.
> 
>      From a functional standpoint this works fine, but it doesn't really
>     perform. If I create a new object in withMapping. I would need to create
>     a new HashSet/Aggregate for each element in ParallelArray.
> 
> 
> Aren't you effectively doing the same thing in your combineReduce examples?
> 
> --tim
> 

No, only one for each thread:
T1:
Aggregate a=combine(1, null); <- Create new Aggregate
           a=combine(2, a); <-returns a
           a=combine(3, a); <-returns a
....
T2:
Aggregate a=combine(8, null); <- Create new Aggregate
           a=combine(9, a); <-returns a
           a=combine(10, a); <-returns a
....
public Aggregate combine(Integer t, Aggregate u) {
          if (u == null) {
              u = new Aggregate();
          }
          u.count++;
          u.sum += t;
          return u;
}

- Kasper


More information about the Concurrency-interest mailing list