diff --git a/src/docbkx/reference/riak.xml b/src/docbkx/reference/riak.xml
index 4d1d6dfe9..9a50349c1 100644
--- a/src/docbkx/reference/riak.xml
+++ b/src/docbkx/reference/riak.xml
@@ -161,7 +161,7 @@ public class Example {
// If your entry is Content-Type: application/octet-stream,
// you can access the raw bytes.
- byte[] b = riak.getAsBytes(bucket, key); // No conversion at all
+ byte[] b = riak.getAsBytes(bucket, key);
}
}
@@ -170,6 +170,168 @@ public class Example {
+
+ Linking Entries
+
+ Riak has the ability to link entries together using an arbitrary tag. This relationship information is stored in the Link header. The RiakTemplate exposes a method for linking entries together called link. Its usage is quite simple:
+
+ A link is uni-directional, so keep in mind that the bucket and key you pass first should be that of the child (or target) object and the second set of bucket/key pairs you pass to the link method is the source of the relationship. It's this second entry that will receive an updated Link header that points to the child or target entry.
+
+
+
+ Now, querying the metadata on the entry at sourcebucket:sourcekey will result in a Link header that points to the child object: </riak/childbucket/childkey>; riaktag="tagname"
+
+
+
+
+ Link Walking
+
+ When entries are linked together in Riak, those relationships can be efficiently traversed on the server using a feature called Link Walking. Rather than requesting each object in a link's relationship individually, a link walk pulls all the related objects at once and sends that data back to the client as MIME-encoded multipart data. As such, it requires special processing to convert those multiple entries into a List of objects, just as if you had used a get method. If you don't specify a type to convert the objects to, the linkWalk method will try to infer it from the bucket name. If the bucket name is not a valid class name, it will default to using a java.util.Map.
+
+ To link walk a relationship and return a list of custom POJOs, you would do something like this:
+ result = riak.linkWalk("sourcebucket", "sourcekey", "tagname", MyPojo.class);
+ ]]>
+
+
+
+
+
+ Map/Reduce
+
+ Riak supports Map/Reduce functionality in a couple different ways. You can specify the Javascript source to execute (termed "anonymous" Javascript), you can reference some Javascript already stored in Riak at a specfic bucket and key, or you can reference an Erlang module and function. The Map/Reduce support in SDKV covers all these bases by giving you meaningful abstractions over the Map/Reduce job that represent the various aspects of the Map/Reduce process.
+
+ At the highest level, every Map/Reduce request is represented by a MapReduceJob. The MapReduceJob represents the inputs, the phases, and the optional arg to send to Riak to execute the Map/Reduce job. The toJson method is responsible for serializing the entire job into the appropriate JSON data to send to Riak.
+
+
+
+
+ Defining Phases
+
+ Map/Reduce operations in Riak are broken up into phases. Phases contain a MapReduceOperation. There are currently two implementations to handle Javascript or Erlang M/R operations: JavascriptMapReduceOperation and ErlangMapReduceOperation.
+
+ An example Map/Reduce job defining a single "map" phase defined in anonymous Javascript might look like this:
+ bucket = new ArrayList() {{
+ add("mybucket");
+}};
+
+job.addInputs(bucket); // M/R the entire bucket
+
+MapReduceOperation mapOper = new JavascriptMapReduceOperation("function(v){ ...M/R function body... }");
+MapReducePhase mapPhase = new RiakMapReducePhase("map", "javascript", mapOper);
+
+job.addPhase(mapPhase);
+ ]]>
+
+
+
+
+ Executing and Working with the Result
+
+ To execute a configured job on your Riak server, use either the synchronous execute or asynchronous submit methods of your configured RiakTemplate:
+
+
+
+...or...
+
+List o = riak.execute(job, MyPojo.class); // Coerce to given type
+
+...or...
+
+Future> f = riak.submit(job); // Job runs in a separate thread
+ ]]>
+
+
+
+
+
+ Managing Bucket Properties
+
+ It's sometimes useful to manage settings like the Quality-of-Service parameters w and dw (write and durable write thresholds) and the n_val setting at the bucket level. It's also possible to list the keys in a particular bucket by calling the getBucketSchema method, passing true as the second parameter, which tells the RiakTemplate to list the keys.
+
+ To list the keys in a bucket, you would do something like this:
+
+ schema = riak.getBucketSchema("mybucket");
+List keys = schema.get("keys")
+for(String key : keys) {
+ ...do something with each key...
+}
+ ]]>
+
+
+ To update the bucket settings, pass a Map of properties:
+
+ props = new HashMap();
+props.put("n_val", 6);
+props.put("dw", 3);
+
+riak.updateBucketSchema("mybucket", props);
+ ]]>
+
+ Only the properties specified in the passed-in Map will be updated. Properties that have already been set in previous operations and not specified in this operation will be unaffected.
+
+
+
+