Reputation: 69920
I'm new to Riak and new to Erlang. I have successfully created and run JS MapReduce jobs, now I'm trying to execute the following Reduce function:
http://web.archive.org/web/20130329021000/http://contrib.basho.com/delete_keys.html
What are the steps to execute this reduce function? Specifically,
addReducePhase( )
?Thanks
Upvotes: 1
Views: 1320
Reputation: 3869
You should write something like:
MapReduceResult result = client.mapReduce("myBucket")
.addLinkPhase("bucketX", "test", false)
.addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), false)
.addReducePhase(new NamedErlangFunction("riak_kv_mapreduce", "reduce_sort"), true)
.execute();
In this case the reduce phase call the function reduce_sort of erlang module riak_kv_mapreduce. In your case you should call
.addReducePhase(new NamedErlangFunction("reduce_functions", "delete"), true)
(the true at the end is a flag that set if results have to be returned to client - last step - or not -intermediate step -)
The Erlang files should be compiled as .beam before use and added to 'add_paths' parameters in riak.config like
{add_paths, ["/home/vinz/riak/custom_modules/"]}
where /home/vinz/riak/custom_modules is the directory containing the compiled Erlang modules.
Refer to Basho Java Client readme for further information. I hope this helps!
Upvotes: 4