public final class UpdateValue extends RiakCommand<UpdateValue.Response,Location>
The UpdateValue command completely encapsulates the typical read/modify/write cycle used with data in Riak.
The object specified by the given Location
will be fetched from Riak and have the ConflictResolver
stored in
the ConflictResolverFactory
applied. The resolved
object is then passed to your UpdateValue.Update
and the result stored back into Riak.
To create the mutation you wish to perform, you extend the
UpdateValue.Update
class:
class AppendUpdate extends UpdateValue.Update<MyPojo>
{
private final String update;
public AppendUpdate(String update)
{
this.update = update;
}
{@literal @Override}
public MyPojo apply(MyPojo original)
{
if (original == null)
{
original = new MyPojo();
}
original.value += update;
return original;
}
}
Namespace ns = new Namespace("my_type", "my_bucket");
Location loc = new Location(ns, "my_key");
AppendUpdate update = new AppendUpdate("append this string");
UpdateValue uv =
new UpdateValue.Builder(loc).withUpdate(update).build();
UpdateValue.Response response = client.execute(uv);
Modifier and Type | Class and Description |
---|---|
static class |
UpdateValue.Builder
Used to construct an UpdateValue command.
|
static class |
UpdateValue.Response |
static class |
UpdateValue.Update<T>
An update on a Riak object
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
protected RiakFuture<UpdateValue.Response,Location> |
executeAsync(RiakCluster cluster) |
int |
hashCode() |
String |
toString() |
execute, execute
protected RiakFuture<UpdateValue.Response,Location> executeAsync(RiakCluster cluster)
executeAsync
in class RiakCommand<UpdateValue.Response,Location>
Copyright © 2016. All rights reserved.