Matthew, The Ruby client gets a little clever here and tries to determine which kind of phase you are submitting. If its a String that starts with "function", it assumes you are passing the source. Otherwise, it assumes you are using a built-in JS function. If you want to use an Erlang function, use an Array of two elements like so:
mr.reduce(["riak_kv_mapreduce","reduce_sum"], :keep => true) I'd appreciate any ideas on how to improve that API. Sean Cribbs <[email protected]> Developer Advocate Basho Technologies, Inc. http://basho.com/ On Jun 15, 2010, at 3:02 PM, matthew rathbone wrote: > Hi all, > > Does anyone know how I can specify one of the pre-existing javascript > functions when running a map-reduce from ruby? > > For example, I want to run a reduce method that 1) specifies that I'm not > creating an anonymous function, and 2) calls one of the predefined functions, > eg 'reduce_sum' (as seen here: > http://bitbucket.org/basho/riak/src/tip/apps/riak_kv/src/riak_kv_mapreduce.erl) > > Any ideas? > > I know how to do it with an anonymous function: > reduce("function(values, arg){ > sum = 0; > > values.forEach(function(x){sum = sum + x;}); > return > [sum]; > }" , nil, > :keep => true).run > _______________________________________________ > riak-users mailing list > [email protected] > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
_______________________________________________ riak-users mailing list [email protected] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
