Best practice for using erlang modules in riak?

Sylvain Niles sylvain.niles at gmail.com
Fri May 27 15:16:14 EDT 2011


Still looking for advice on this, additionally I'm looking for the
correct way to call the erlang modules from Ripple. I've tried calling
it from a reduce like so:

reduced = Riak::MapReduce.new(Ripple.client).add(a-bucket').map("function(v){return
[[v.values[0].data], [v.bucket, v.key]];}", :keep =>
true).reduce(["my_module","my_function"], :keep => true).run

and I can see that it never gets called, just returns [].

I can call the module while attached to a Riak console in the cluster
and it works exactly as expected given the exact output of the
previous map: [["value"], ["bucket", "key"]]

Any pointers would be greatly appreciated! If there's any open source
code out there using ripple in this fashion I'd love a pointer!

Thanks,
-Sylvain

On Tue, May 24, 2011 at 6:55 PM, Sylvain Niles <sylvain.niles at gmail.com> wrote:
> So I've seen a few well written examples of erlang map or reduce
> functions in the contrib section of the wiki/github but the missing
> piece of glue for me is: Where do I compile from? I've done a lot of
> ejabberd development and generally I just throw it in the src
> directory, add a config param to the ejabberd.conf to load my new
> module at startup, make install, and I'm done. Should I be deploying
> my modules to /deps/riak_core/src/?
>
> The wiki has this note:
>
> Distributing Erlang MapReduce Code
>
> Any modules and functions you use in your Erlang MapReduce calls must
> be available on all nodes in the cluster. You can add them in Erlang
> applications by specifying the -pz option in vm.args or by adding the
> path to the add_paths setting in app.config.
>
> But the vm.args page does not list the valid config format/options for
> the -pz option. Is the add_paths behavior such that a valid beam in
> that dir will automatically be loaded on startup and all exported
> functions available? What about live code updates of internally
> developed modules?
>
> Thanks in advance!
>
> -Sylvain
>



More information about the riak-users mailing list