map function for link-walking

Bryan Fink bryan at basho.com
Sun Jul 11 11:03:07 EDT 2010


On Sun, Jul 11, 2010 at 9:19 AM, Nicolas Fouché <nicolas at silentale.com> wrote:
> I did not find any doc about preloading javascript functions. Is it
> the same as storing JS files in a bucket and load them thanks to the
> "bucket" and "key" fields, as described in the "Map" paragraph of the
> Fast Track ? https://wiki.basho.com/display/RIAK/Loading+Data+and+Running+MapReduce+Queries

Oops.  You're right - we haven't documented this feature well.  The
best I've found is Kevin Smith's reply to another thread on this list:

http://markmail.org/message/bc7ufl2z42yu6dmg

It involves modifying your app.config file to set the js_source_dir
variable for the riak_kv app.  For a good example of how to structure
a preloaded-JS file, check out the one that ships with Riak:

http://bitbucket.org/basho/riak/src/tip/apps/riak_kv/priv/mapred_builtins.js

All of the functions in that file are available to Javascript
map/reduce functions as Riak.<function name>.  Those functions will
still be available even after you set js_source_dir.  You might
consider wrapping your application's useful functions in a MyApp class
or some such.

It's also useful to know about "bin/riak-admin js_reload" if you're
doing this.  That command will re-read all of your preloaded
Javascript files.

-Bryan




More information about the riak-users mailing list