我不知道在使用 gmongo 时如何设置 Finalizer。我的 'reduce' 包含一个我想在 'Finalize' 中使用的数组
Map和Reduce如下图
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"
当我如下调用 mapreduce 时,出现错误 - 查询太大
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..
只有这对我有用,但不知道如何设置 Finalize
logCollection.mapReduce(map,reduce,collection,[:])