Erlang Map/Reduce error

Kresten Krab Thorup krab at
Tue Oct 4 05:24:15 EDT 2011

The error badfun most likely means that the function's code is not available inside Riak.

You need to add {add_paths, "/path/to/your/ebin"} in the riak_kv section in app.config.  Read more about it here

For an explanation of why the badfun happens, you can read this blog:
... which can also give you an idea to how to do it without loading the code into riak, i.e. something like this may likely work, but will invoke the interpreter inside riak; which may be too slow for your needs.


1> FunStr = "fun(O, undefined, none) -> [riak_object:get_value(O)] end.".
2> {ok, Tokens, _} = erl_scan:string(FunStr).
3> {ok, [Form]} = erl_parse:parse_exprs(Tokens).
4> Bindings = erl_eval:add_binding('B', 2, erl_eval:new_bindings()).
5> {value, Fun, _} = erl_eval:expr(Form, Bindings).
6> C:mapred([{<<"buck">>, <<"key1">>}, {<<"buck">>, <<"key2">>}], [{map, {qfun, Fun}, none, true}]).


On Oct 4, 2011, at 11:00 AM, Lyes Amazouz wrote:

Hi everybody,

I'm learning how to execute a map/reduce using the riak_client module, so I tried this:

>Map = fun(O, undefined, none) -> [riak_object:get_value(O)] end.
>C:mapred([{<<"buck">>, <<"key1">>}, {<<"buck">>, <<"key2">>}], [{map, {qfun, Map}, none, true}]).

but I got  this error:


What is wring with my code??
riak-users mailing list
riak-users at<mailto:riak-users at>

More information about the riak-users mailing list