Search in sources :

Example 1 with Key

use of oracle.kv.Key in project YCSB by brianfrankcooper.

the class NoSqlDbClient method update.

@Override
public Status update(String table, String key, HashMap<String, ByteIterator> values) {
    for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
        Key kvKey = createKey(table, key, entry.getKey());
        Value kvValue = Value.createValue(entry.getValue().toArray());
        try {
            store.put(kvKey, kvValue);
        } catch (FaultException e) {
            System.err.println(e);
            return Status.ERROR;
        }
    }
    return Status.OK;
}
Also used : FaultException(oracle.kv.FaultException) ByteArrayByteIterator(com.yahoo.ycsb.ByteArrayByteIterator) ByteIterator(com.yahoo.ycsb.ByteIterator) Value(oracle.kv.Value) HashMap(java.util.HashMap) Map(java.util.Map) SortedMap(java.util.SortedMap) Key(oracle.kv.Key)

Example 2 with Key

use of oracle.kv.Key in project YCSB by brianfrankcooper.

the class NoSqlDbClient method read.

@Override
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
    Key kvKey = createKey(table, key);
    SortedMap<Key, ValueVersion> kvResult;
    try {
        kvResult = store.multiGet(kvKey, null, null);
    } catch (FaultException e) {
        System.err.println(e);
        return Status.ERROR;
    }
    for (Map.Entry<Key, ValueVersion> entry : kvResult.entrySet()) {
        /* If fields is null, read all fields */
        String field = getFieldFromKey(entry.getKey());
        if (fields != null && !fields.contains(field)) {
            continue;
        }
        result.put(field, new ByteArrayByteIterator(entry.getValue().getValue().getValue()));
    }
    return Status.OK;
}
Also used : FaultException(oracle.kv.FaultException) ByteArrayByteIterator(com.yahoo.ycsb.ByteArrayByteIterator) ValueVersion(oracle.kv.ValueVersion) HashMap(java.util.HashMap) Map(java.util.Map) SortedMap(java.util.SortedMap) Key(oracle.kv.Key)

Aggregations

ByteArrayByteIterator (com.yahoo.ycsb.ByteArrayByteIterator)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 SortedMap (java.util.SortedMap)2 FaultException (oracle.kv.FaultException)2 Key (oracle.kv.Key)2 ByteIterator (com.yahoo.ycsb.ByteIterator)1 Value (oracle.kv.Value)1 ValueVersion (oracle.kv.ValueVersion)1