我正在尝试从Cassandra database
使用中读取数据Pelops client
。我能够成功地做到这一点。
现在我已经开始做benchmarking
,这意味着从 Cassandra 数据库读取需要多少时间。所以我benchmarking code
在下面的代码中添加了我的。
现在我不确定我是否benchmarking code
在正确的位置添加了我的来测量Cassandra database
使用的读取延迟Pelops client
?
下面是我的代码-
public Map<String, String> getAttributes(final String rowKey, final Collection<String> attributeNames, final String columnFamily) {
final Map<String, String> attributes = new ConcurrentHashMap<String, String>();
try {
final SlicePredicate myPredicate = Selector.newColumnsPredicate(attributeNames.toArray(new String[attributeNames.size()]));
final Selector selector = Pelops.createSelector(CassandraPelopsConnection.getInstance().getPoolName());
// this is the right place to start the timer?
CassandraTimer timer = CassandraTimer.getInstance();
final List<Column> columnList = selector.getColumnsFromRow(columnFamily, rowKey, myPredicate, ConsistencyLevel.ONE);
// And this is the right place to end the timer incase of Pelops client?
timer.getDuration();
for (Column column : columnList) {
attributes.put(new String(column.getName()), new String(column.getValue()));
}
} catch (Exception e) {
}
return attributes;
}
任何人都可以看看,让我知道我是否做得对吗?