Search in sources :

Example 1 with DeleteValue

use of com.basho.riak.client.api.commands.kv.DeleteValue in project YCSB by brianfrankcooper.

the class RiakKVClient method delete.

/**
   * Delete a record from the database.
   *
   * @param table The name of the table (Riak bucket)
   * @param key   The record key of the record to delete.
   * @return Zero on success, a non-zero error code on error
   */
@Override
public Status delete(String table, String key) {
    Location location = new Location(new Namespace(bucketType, table), key);
    DeleteValue dv = new DeleteValue.Builder(location).build();
    RiakFuture<Void, Location> future = riakClient.executeAsync(dv);
    try {
        future.get(transactionTimeLimit, TimeUnit.SECONDS);
    } catch (TimeoutException e) {
        if (debug) {
            System.err.println("Unable to delete key " + key + ". Reason: TIME OUT");
        }
        return TIME_OUT;
    } catch (Exception e) {
        if (debug) {
            System.err.println("Unable to delete key " + key + ". Reason: " + e.toString());
        }
        return Status.ERROR;
    }
    return Status.OK;
}
Also used : DeleteValue(com.basho.riak.client.api.commands.kv.DeleteValue) Namespace(com.basho.riak.client.core.query.Namespace) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) Location(com.basho.riak.client.core.query.Location) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

DeleteValue (com.basho.riak.client.api.commands.kv.DeleteValue)1 Location (com.basho.riak.client.core.query.Location)1 Namespace (com.basho.riak.client.core.query.Namespace)1 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1