use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class RadosClient method read.
@Override
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
byte[] buffer;
try {
RadosObjectInfo info = ioctx.stat(key);
buffer = new byte[(int) info.getSize()];
ReadOp rop = ioctx.readOpCreate();
ReadResult readResult = rop.queueRead(0, info.getSize());
// TODO: more size than byte length possible;
// rop.operate(key, Rados.OPERATION_NOFLAG); // for rados-java 0.3.0
rop.operate(key, 0);
// readResult.raiseExceptionOnError("Error ReadOP(%d)", readResult.getRVal()); // for rados-java 0.3.0
if (readResult.getRVal() < 0) {
throw new RadosException("Error ReadOP", readResult.getRVal());
}
if (info.getSize() != readResult.getBytesRead()) {
return new Status("ERROR", "Error the object size read");
}
readResult.getBuffer().get(buffer);
} catch (RadosException e) {
return new Status("ERROR-" + e.getReturnValue(), e.getMessage());
}
JSONObject json = new JSONObject(new String(buffer, java.nio.charset.StandardCharsets.UTF_8));
Set<String> fieldsToReturn = (fields == null ? json.keySet() : fields);
for (String name : fieldsToReturn) {
result.put(name, new StringByteIterator(json.getString(name)));
}
return result.isEmpty() ? Status.ERROR : Status.OK;
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class RadosClientTest method updateTest.
@Test
public void updateTest() {
radosclient.insert(TABLE_NAME, KEY2, DATA);
Status result = radosclient.update(TABLE_NAME, KEY2, DATA_UPDATED);
assertEquals(Status.OK, result);
HashMap<String, ByteIterator> ret = new HashMap<String, ByteIterator>(10);
radosclient.read(TABLE_NAME, KEY2, DATA.keySet(), ret);
compareMap(DATA_UPDATED, ret);
radosclient.delete(TABLE_NAME, KEY2);
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class RadosClientTest method deleteTest.
@Test
public void deleteTest() {
Status result = radosclient.delete(TABLE_NAME, KEY0);
assertEquals(Status.OK, result);
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class RadosClientTest method readTest.
@Test
public void readTest() {
HashMap<String, ByteIterator> ret = new HashMap<String, ByteIterator>(10);
Status result = radosclient.read(TABLE_NAME, KEY0, DATA.keySet(), ret);
assertEquals(Status.OK, result);
compareMap(DATA, ret);
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class IgniteSqlClientTest method testInsert.
@Test
public void testInsert() throws Exception {
cluster.cache(DEFAULT_CACHE_NAME).clear();
final String key = "key";
final Map<String, String> input = new HashMap<>();
input.put("field0", "value1");
input.put("field1", "value2");
final Status status = client.insert(TABLE_NAME, key, StringByteIterator.getByteIteratorMap(input));
assertThat(status, is(Status.OK));
assertThat(cluster.cache(DEFAULT_CACHE_NAME).size(), is(1));
}
Aggregations