use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class AsyncHBaseTest method testReadMissingRow.
@Test
public void testReadMissingRow() throws Exception {
final HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
final Status status = client.read(tableName, "Missing row", null, result);
assertEquals(Status.NOT_FOUND, status);
assertEquals(0, result.size());
}
use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class AzureClient method insertBatch.
private Status insertBatch(String key, HashMap<String, ByteIterator> values) {
HashMap<String, EntityProperty> properties = new HashMap<String, EntityProperty>();
for (Entry<String, ByteIterator> entry : values.entrySet()) {
String fieldName = entry.getKey();
byte[] fieldVal = entry.getValue().toArray();
properties.put(fieldName, new EntityProperty(fieldVal));
}
DynamicTableEntity entity = new DynamicTableEntity(partitionKey, key, properties);
BATCH_OPERATION.insertOrReplace(entity);
if (++curIdx == batchSize) {
try {
cloudTable.execute(BATCH_OPERATION);
BATCH_OPERATION.clear();
curIdx = 0;
} catch (Exception e) {
return Status.ERROR;
}
}
return Status.OK;
}
use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class AzureClient method readEntity.
private Status readEntity(String key, HashMap<String, ByteIterator> result) {
try {
// firstly, retrieve the entity to be deleted
TableOperation retrieveOp = TableOperation.retrieve(partitionKey, key, DynamicTableEntity.class);
DynamicTableEntity entity = cloudTable.execute(retrieveOp).getResultAsType();
HashMap<String, EntityProperty> properties = entity.getProperties();
for (Entry<String, EntityProperty> entry : properties.entrySet()) {
String fieldName = entry.getKey();
ByteIterator fieldVal = new ByteArrayByteIterator(entry.getValue().getValueAsByteArray());
result.put(fieldName, fieldVal);
}
return Status.OK;
} catch (Exception e) {
return Status.ERROR;
}
}
use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class AzureClient method readSubset.
/*
* Read subset of properties instead of full fields with projection.
*/
public Status readSubset(String key, Set<String> fields, HashMap<String, ByteIterator> result) {
String whereStr = String.format("RowKey eq '%s'", key);
TableQuery<TableServiceEntity> projectionQuery = TableQuery.from(TableServiceEntity.class).where(whereStr).select(fields.toArray(new String[0]));
EntityResolver<HashMap<String, ByteIterator>> resolver = new EntityResolver<HashMap<String, ByteIterator>>() {
public HashMap<String, ByteIterator> resolve(String partitionkey, String rowKey, Date timeStamp, HashMap<String, EntityProperty> properties, String etag) {
HashMap<String, ByteIterator> tmp = new HashMap<String, ByteIterator>();
for (Entry<String, EntityProperty> entry : properties.entrySet()) {
String key = entry.getKey();
ByteIterator val = new ByteArrayByteIterator(entry.getValue().getValueAsByteArray());
tmp.put(key, val);
}
return tmp;
}
};
try {
for (HashMap<String, ByteIterator> tmp : cloudTable.execute(projectionQuery, resolver)) {
for (Entry<String, ByteIterator> entry : tmp.entrySet()) {
String fieldName = entry.getKey();
ByteIterator fieldVal = entry.getValue();
result.put(fieldName, fieldVal);
}
}
return Status.OK;
} catch (Exception e) {
return Status.ERROR;
}
}
use of com.yahoo.ycsb.ByteIterator in project YCSB by brianfrankcooper.
the class CassandraCQLClientTest method testReadMissingRow.
@Test
public void testReadMissingRow() throws Exception {
final HashMap<String, ByteIterator> result = new HashMap<String, ByteIterator>();
final Status status = client.read(TABLE, "Missing row", null, result);
assertThat(result.size(), is(0));
assertThat(status, is(Status.NOT_FOUND));
}
Aggregations