I do not know how to set Finalizer when using gmongo. My 'reduce' contains an Array that I want to use in 'Finalize'
Map and Reduce are as shown below
String map="""
function map(){
key = this.vendor
var inSec=Math.round(this.timeTook/1000*100)/100
value= {response_time:[inSec]}
emit(key, value)
}
"""
String reduce = """
function reduce(key,values){
var call_list={response_time:[]}
var count = 0
var total=0
for (var i in values){
call_list.response_time=values[i].response_time.concat(call_list.response_time)
}
call_list.response_time= call_list.response_time.sort(function(a,b){return a-b})
return call_list
}
"""
String collection="mapreduceresult"
When I invoke mapreduce as below, I get an error - query too large
MapReduceCommand cmd = new MapReduceCommand(logCollection, map,reduce,null,MapReduceCommand.OutputType.MERGE,null)
cmd.setOutputDB(collection)
cmd.setFinalize(finalizer) //- wanted to use Finalize as the reducer returns an Array
logCollection.mapReduce(cmd) //This is giving an error - Query is too large..
Only this is working for me but do not know how to set Finalize
logCollection.mapReduce(map,reduce,collection,[:])