Hi,
I'm not sure if this is a riak or an erlang specific question. I'm guessing
it's probably an erlang question.
I have the following erlang function in a module, mapreduce_play.erl (it's a
silly skeleton function, but I'm just playing around):
get_objects(Server, Port, Bucket, FilterList) ->
{ok, Client} = riakc_pb_socket:start(Server, Port),
Input = {Bucket, [FilterList]},
MapFun = fun(Object, _KeyData, _Args) ->
[Object]
end,
MapPhase = {map, {qfun, MapFun}, notused, true},
Query = [MapPhase],
riakc_pb_socket:mapred(Client, Input, Query).
If I copy the function body, line for line into the erlang shell, replacing
values as I go along, the code works fine, and I get results back correctly.
However, If I call the function, in the same shell, I get the following error:
{error,<<"{error,\n {error,undef,\n
[{#Fun<mapreduce_play.0.108144614>,\n
[{r_object,<<\"family\">>,<<"...>>}
This is not what I expected to happen. Has this got something to do with the
nature of the anonymous function, one being defined in the shell and the other
in a module? I've seen this link:
http://blog.inagist.com/link-map-reduce-in-riak-an-example-from-inagi
Which at the end of the post has the following :
"Of interest is the make_local_fun which creates a function reference which can
be passed over to a remote node, without the remote node having a copy of this
compiled code in its path"
So, why does passing the anonymous function defined in the shell work, but it
fails when the anonymous function was defined inside a module?
Thanks,
Ryan_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com