Map Function in Erlang with PBC

Ryan Maclear ryan at lambdasphere.com
Wed Feb 9 14:26:59 EST 2011


Hi Kresten,

Thanks for the blog post and the explanation therein - it now makes much more sense to me. I don't necessarily want to put all my m/r functions in a module on the cluster, so I would need to pass them from a client node, but I wasn't too keen to follow the method where the code is interpreted upon calling apply. The method from TrapExit seems like a better option for me.  

Cheers,
Ryan



On 09 Feb 2011, at 4:42 PM, Kresten Krab Thorup wrote:

> It looks like your problem is that the code is not on the server, so yes, ... I think that your guess is right.  Here's a blg I wrote a while back on this topic
> 
> http://www.javalimit.com/2010/05/passing-funs-to-other-erlang-nodes.html
> 
> ... which also describes why it works for the case where you enter the code in the shell; it creates an interpreted function structure which *is* usable across erlang nodes.
> 
> Kresten
> 
> 
> On Feb 9, 2011, at 9:22 , Ryan Maclear wrote:
> 
> 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:
> 
> 




More information about the riak-users mailing list