我正在尝试使用riak-ruby-client编写 riak map reduce 。Javascript reduce 函数如下所示:
arr.reduce(callback,[initialValue]);
我正在做这样的事情:
map_reduce = Riak::MapReduce.new(Ripple.client)
map_reduce.add(bucket) // I have passed a valid bucket
var callback = "function(previous, current){return previous + current;}"
results = map_reduce.map(map_func).reduce(callback,1,:keep=>true).run //1 is the initial value as in javascript reduce func.
但 riak 并没有将 1 视为此处的初始值。有人能告诉我如何通过初始值来减少阶段吗?