use of com.toshiba.mwcloud.gs.Row in project YCSB by brianfrankcooper.
the class GridDBClient method update.
public Status update(String table, String key, Map<String, ByteIterator> values) {
try {
Object rowKey = makeRowKey(key);
String containerKey = makeContainerKey(key);
final Container<Object, Row> container = store.getContainer(containerKey);
if (container == null) {
LOGGER.severe("[ERROR]getCollection " + containerKey + " in update()");
return Status.ERROR;
}
Row targetRow = container.get(rowKey);
if (targetRow == null) {
LOGGER.severe("[ERROR]get(rowKey) in update()");
return Status.ERROR;
}
int setCount = 0;
for (int i = 1; i < containerInfo.getColumnCount() && setCount < values.size(); i++) {
containerInfo.getColumnInfo(i).getName();
ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName());
if (byteIterator != null) {
Object value = makeValue(byteIterator);
targetRow.setValue(i, value);
setCount++;
}
}
if (setCount != values.size()) {
LOGGER.severe("Error setCount = " + setCount);
return Status.ERROR;
}
container.put(targetRow);
return Status.OK;
} catch (GSException e) {
LOGGER.severe("Exception: " + e.getMessage());
return Status.ERROR;
}
}
use of com.toshiba.mwcloud.gs.Row in project YCSB by brianfrankcooper.
the class GridDBClient method insert.
public Status insert(String table, String key, Map<String, ByteIterator> values) {
try {
Object rowKey = makeRowKey(key);
String containerKey = makeContainerKey(key);
final Container<Object, Row> container = store.getContainer(containerKey);
if (container == null) {
LOGGER.severe("[ERROR]getCollection " + containerKey + " in insert()");
}
Row row = container.createRow();
row.setValue(ROW_KEY_COLUMN_POS, rowKey);
for (int i = 1; i < containerInfo.getColumnCount(); i++) {
ByteIterator byteIterator = values.get(containerInfo.getColumnInfo(i).getName());
Object value = makeValue(byteIterator);
row.setValue(i, value);
}
container.put(row);
} catch (GSException e) {
LOGGER.severe("Exception: " + e.getMessage());
return Status.ERROR;
}
return Status.OK;
}
use of com.toshiba.mwcloud.gs.Row in project YCSB by brianfrankcooper.
the class GridDBClient method read.
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
try {
Object rowKey = makeRowKey(key);
String containerKey = makeContainerKey(key);
final Container<Object, Row> container = store.getContainer(containerKey);
if (container == null) {
LOGGER.severe("[ERROR]getCollection " + containerKey + " in read()");
return Status.ERROR;
}
Row targetRow = container.get(rowKey);
if (targetRow == null) {
LOGGER.severe("[ERROR]get(rowKey) in read()");
return Status.ERROR;
}
for (int i = 1; i < containerInfo.getColumnCount(); i++) {
result.put(containerInfo.getColumnInfo(i).getName(), new ByteArrayByteIterator(targetRow.getValue(i).toString().getBytes()));
}
return Status.OK;
} catch (GSException e) {
LOGGER.severe("Exception: " + e.getMessage());
return Status.ERROR;
}
}
Aggregations