Anonymous avatar Anonymous committed 8e36fb7

fill out details about specifying link-extraction functions in Javascript

Comments (0)

Files changed (1)

doc/js-mapreduce.org

     Return the empty list if your reduce function chooses not to
     produce output.
 
-*** TODO Link functions
+*** Link functions
+
+    If you're storing data through the "raw" interface, and using the
+    =Link= HTTP header, you don't need to worry about writing a
+    link-extraction function.  Just use the predefined
+    =raw_link_walker_resource:mapreduce_linkfun/3=.
+
+    But, if you need to extract links from your data in some other
+    manner, there are many ways to specify Javascript functions to do
+    that.  They all start with setting the =linkfun= bucket property.
+    Through the raw HTTP interface:
+
+:$ curl -X PUT -H "application/json" http://localhost:8098/raw/bucket \
+:> --data "{\"props\":{\"linkfun\":{...function...}}}"
+
+    The three ways to fill in the value of the =linkfun= key are:
+
+    + Quoted source code, as the value of the =jsanon= key:
+
+      :{"jsanon":"function(v,kd,bt) { return []; }"}
+
+    + The bucket and key of an object containing the function source:
+
+      :{"jsanon":{"bucket":Bucket,"key":Key}}
+
+    + The name of a predefined Javascript function:
+
+      :{"jsfun":FunctionName}
+
+    The function has basically the same contract as a map function.
+    The first argument is the object from which links should be
+    extracted.  The second argument is the =KeyData= for the object.
+
+    The third argument is a Javascript object representing the links
+    to match at return.  The two fields in the object, =bucket= and
+    =tag=, will have the values given in the link phase spec from the
+    query.
+
+    The link fun should return a list of the same form as the =inputs=
+    list: 2-item bucket/key lists, or 3-item bucket/key/keydata lists.
 
 * TODO How M/R works on Riak
   I'm thinking of moving some content from basic-mapreduce.txt into
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.