driver-legacy/src/main/com/mongodb/DBCollection.java
public MapReduceOutput mapReduce(final String map, final String reduce, final String outputTarget,
                                     final MapReduceCommand.OutputType outputType, final DBObject query,
                                     final ReadPreference readPreference) {
        MapReduceCommand command = new MapReduceCommand(this, map, reduce, outputTarget, outputType, query);
        command.setReadPreference(readPreference);
        return mapReduce(command);
    }
public MapReduceOutput mapReduce(final String map, final String reduce, final String outputTarget,
                                     final MapReduceCommand.OutputType outputType, final DBObject query,
                                     final ReadPreference readPreference) {
        MapReduceCommand command = new MapReduceCommand(this, map, reduce, outputTarget, outputType, query);
        command.setReadPreference(readPreference);
        return mapReduce(command);
    }
Allows you to run map-reduce aggregation operations over a collection and saves to a named collection.

@param map            a JavaScript function that associates or "maps" a value with a key and emits the key and value pair.
@param reduce         a JavaScript function that "reduces" to a single object all the values associated with a particular key.
@param outputTarget   specifies the location of the result of the map-reduce operation.
@param outputType     specifies the type of job output
@param query          specifies the selection criteria using query operators for determining the documents input to the map
function.
@param readPreference the read preference specifying where to run the query.  Only applied for Inline output type
@return a MapReduceOutput which contains the results of this map reduce operation
@mongodb.driver.manual core/map-reduce/ Map-Reduce