Note that add_paths must be a list of paths, e.g. {add_paths,
["/path/to/your/ebin","/path/to/your/other/ebin"]}.On Tue, Oct 4, 2011 at 5:24 AM, Kresten Krab Thorup <[email protected]>wrote: > 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 > http://wiki.basho.com/MapReduce.html#MapReduce-via-the-Erlang-API > > For an explanation of why the badfun happens, you can read this blog: > http://www.javalimit.com/2010/05/passing-funs-to-other-erlang-nodes.html > ... 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. > > Kresten > > > 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}]). > > > Kresten > > > > > 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: > > {error,{error,{badfun,#Fun<erl_eval.18.59269574>}, > [{riak_kv_mapper,run_map,9}, > {riak_kv_mapper,'-do_map/2-fun-0-',9}, > {lists,foldl,3}, > {riak_kv_mapper,do_map,2}, > {gen_fsm,handle_msg,7}, > {proc_lib,init_p_do_apply,3}]}} > > What is wring with my code?? > _______________________________________________ > riak-users mailing list > [email protected]<mailto:[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 > -- Sean Cribbs <[email protected]> Developer Advocate Basho Technologies, Inc. http://www.basho.com/
_______________________________________________ riak-users mailing list [email protected] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
