/** * Transforms a collection into a collection of aggregated groups, by applying a supplied * element-mapping function to each element, that transforms each one into a key-value pair, * grouping the resulting pairs by key, and finally reducing values in each group applying a * suppling 'reduce' function. * * <p>Each supplied function is coded in JavaScript. * * <p>Note that the correct way of writing those functions may not be obvious; please consult * MongoDB documentation for writing them. * * <p>{@sample.xml ../../../doc/mongo-connector.xml.sample mongo:map-reduce-objects} * * @param collection the name of the collection to map and reduce * @param mapFunction a JavaScript encoded mapping function * @param reduceFunction a JavaScript encoded reducing function * @param outputCollection the name of the output collection to write the results, replacing * previous collection if existed, mandatory when results may be larger than 16MB. If * outputCollection is unspecified, the computation is performed in-memory and not persisted. * @return an iterable that retrieves the resulting collection of {@link DBObject} */ @Processor public Iterable<DBObject> mapReduceObjects( String collection, String mapFunction, String reduceFunction, @Optional String outputCollection) { return client.mapReduceObjects(collection, mapFunction, reduceFunction, outputCollection); }