use of com.microsoft.azure.storage.table.TableOperation in project YCSB by brianfrankcooper.
the class AzureClient method delete.
@Override
public Status delete(String table, String key) {
try {
// firstly, retrieve the entity to be deleted
TableOperation retrieveOp = TableOperation.retrieve(partitionKey, key, TableServiceEntity.class);
TableServiceEntity entity = cloudTable.execute(retrieveOp).getResultAsType();
// secondly, delete the entity
TableOperation deleteOp = TableOperation.delete(entity);
cloudTable.execute(deleteOp);
return Status.OK;
} catch (Exception e) {
return Status.ERROR;
}
}
use of com.microsoft.azure.storage.table.TableOperation in project YCSB by brianfrankcooper.
the class AzureClient method insertOrUpdate.
private Status insertOrUpdate(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);
TableOperation insertOrReplace = TableOperation.insertOrReplace(entity);
try {
cloudTable.execute(insertOrReplace);
return Status.OK;
} catch (Exception e) {
return Status.ERROR;
}
}
use of com.microsoft.azure.storage.table.TableOperation 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;
}
}
Aggregations