use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class ElasticsearchClientTest method testRead.
/**
* Test of read method, of class ElasticsearchClient.
*/
@Test
public void testRead() {
Set<String> fields = MOCK_DATA.keySet();
HashMap<String, ByteIterator> resultParam = new HashMap<>(10);
Status result = instance.read(MOCK_TABLE, MOCK_KEY1, fields, resultParam);
assertEquals(Status.OK, result);
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class ElasticsearchIntegTestBase method testRead.
/**
* Test of read method, of class ElasticsearchClient.
*/
@Test
public void testRead() {
final Set<String> fields = MOCK_DATA.keySet();
final HashMap<String, ByteIterator> resultParam = new HashMap<>(10);
final Status result = db.read(MOCK_TABLE, "1", fields, resultParam);
assertEquals(Status.OK, result);
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class ElasticsearchIntegTestBase method testUpdate.
/**
* Test of update method, of class ElasticsearchClient.
*/
@Test
public void testUpdate() {
final HashMap<String, ByteIterator> newValues = new HashMap<>(10);
for (int i = 1; i <= 10; i++) {
newValues.put(FIELD_PREFIX + i, new StringByteIterator("newvalue" + i));
}
final Status updateResult = db.update(MOCK_TABLE, "1", newValues);
assertEquals(Status.OK, updateResult);
// validate that the values changed
final HashMap<String, ByteIterator> resultParam = new HashMap<>(10);
final Status readResult = db.read(MOCK_TABLE, "1", MOCK_DATA.keySet(), resultParam);
assertEquals(Status.OK, readResult);
for (int i = 1; i <= 10; i++) {
assertEquals("newvalue" + i, resultParam.get(FIELD_PREFIX + i).toString());
}
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class ElasticsearchIntegTestBase method testDelete.
/**
* Test of delete method, of class ElasticsearchClient.
*/
@Test
public void testDelete() {
final Status result = db.delete(MOCK_TABLE, "1");
assertEquals(Status.OK, result);
}
use of site.ycsb.Status in project YCSB by brianfrankcooper.
the class CrailClient method read.
@Override
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
try {
String path = table + "/" + key;
CrailKeyValue file = client.lookup(path).get().asKeyValue();
CrailBufferedInputStream stream = file.getBufferedInputStream(1024);
while (stream.available() < Integer.BYTES) {
assert true;
}
int fieldKeyLength = stream.readInt();
while (stream.available() < fieldKeyLength) {
assert true;
}
byte[] fieldKey = new byte[fieldKeyLength];
int res = stream.read(fieldKey);
if (res != fieldKey.length) {
stream.close();
return Status.ERROR;
}
while (stream.available() < Integer.BYTES) {
assert true;
}
int fieldValueLength = stream.readInt();
while (stream.available() < fieldValueLength) {
assert true;
}
byte[] fieldValue = new byte[fieldValueLength];
res = stream.read(fieldValue);
if (res != fieldValue.length) {
stream.close();
return Status.ERROR;
}
result.put(new String(fieldKey), new ByteArrayByteIterator(fieldValue));
stream.close();
return Status.OK;
} catch (Exception e) {
LOG.error("Error during read, table " + table + ", key " + key + ", exception " + e.getMessage());
return new Status("read error", "reading exception");
}
}
Aggregations