"MapReduce-MPI WWW Site"_mws - "MapReduce-MPI Documentation"_md :c

:link(mws,http://www.cs.sandia.gov/~sjplimp/mapreduce.html)
:link(md,Manual.html)

:line

MapReduce add() method :h3

int MapReduce::add(MapReduce *mr2) :pre

This calls the add() method of a MapReduce object, to add the KeyValue
pairs contained in a second MapReduce object mr2, to the KeyValue
object of the first MapReduce object.  This is useful if multiple
MapReduce objects have been created and populated with key/value pairs
and you wish to combine them before performing further operations,
such as a "collate()"_collate.html and "reduce()"_reduce.html.

For example, this sequence of calls:

MapReduce *mr1 = new MapReduce(MPI_COMM_WORLD);
mr1->map(ntasks,&mymap,NULL);
MapReduce *mr2 = mr1->copy();
mr2->collate();
mr2->reduce(&myreduce2,NULL);
mr1->add(mr2);
delete mr2;
mr1->reduce(&myreduce1,NULL); :pre

would generate one set of key/value pairs from the initial
"map()"_map.html operation, then make a "copy"_copy.html of them,
which are then "collated"_collate.html and "reduced"_reduce.html to a
new set of key/value pairs.  The new set of key/value pairs are
"added"_add.html to the original set produced by the "map()"_map.html
operation to form an augmented set of key/value pairs, which could be
further processed.

:line

[Related methods]: "copy"_copy.html, "map()"_map.html
