MapReduce-MPI WWW Site - MapReduce-MPI Documentation

MapReduce add() method

uint64_t MapReduce::add(MapReduce *mr2) 

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, which is created if one does not exist. 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() and reduce().

For example, this sequence of calls:

MapReduce *mr1 = new MapReduce(MPI_COMM_WORLD);
MapReduce *mr2 = mr1->copy();
delete mr2;

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

Related methods: copy, map()