}
@Override
protected Void run() throws Exception {
try {
MutationBatch m = keyspace.prepareMutationBatch().setConsistencyLevel(ConsistencyLevel.CL_QUORUM);
// Setting columns in a standard column
ColumnListMutation<String> cm = m.withRow(columnFamily, rowKey);
for (String key : attributes.keySet()) {
Object o = attributes.get(key);
if (o != null) {
// unfortunately the 'putColumn' method does not nicely figure out what type the Object is so we need to do it manually
if (o instanceof String) {
cm.putColumn(key, (String) o, ttlSeconds);
} else if (o instanceof Boolean) {
cm.putColumn(key, (Boolean) o, ttlSeconds);
} else if (o instanceof Integer) {
cm.putColumn(key, (Integer) o, ttlSeconds);
} else if (o instanceof Long) {
cm.putColumn(key, (Long) o, ttlSeconds);
} else if (o instanceof Double) {
cm.putColumn(key, (Double) o, ttlSeconds);
} else if (o instanceof Date) {
cm.putColumn(key, (Date) o, ttlSeconds);
} else if (o instanceof byte[]) {
cm.putColumn(key, (byte[]) o, ttlSeconds);
} else if (o instanceof ByteBuffer) {
cm.putColumn(key, (ByteBuffer) o, ttlSeconds);
} else {
throw new IllegalArgumentException("Unsupported object instance type: " + o.getClass().getSimpleName());
}
}
}
m.execute();
return null;
} catch (ConnectionException e) {
throw e;
}
}