JacksonDBCollection<Complex, String> resultColl = getCollection(Complex.class, String.class);
complexMapReduce(MapReduce.OutputType.REPLACE, resultColl.getName());
}
private void complexMapReduce(MapReduce.OutputType outputType, String collection) {
coll.insert(new MockObject("foo", 10));
coll.insert(new MockObject("foo", 15));
coll.insert(new MockObject("bar", 5));
MapReduceOutput<Complex, String> output = coll.mapReduce(
MapReduce.build("function() {emit(this.string, {sum: this.integer, product: this.integer});}",
"function(k, vals) {var sum=0,product=1;for(var i in vals){sum+=vals[i].sum;product*=vals[i].product;}return {sum:sum,product:product};}",
outputType, collection, Complex.class, String.class));