【问题标题】:Reading the data from Pelops client and benchmark the read operation从 Pelops 客户端读取数据并对读取操作进行基准测试
【发布时间】:2013-04-17 13:33:53
【问题描述】:

我正在尝试使用Pelops clientCassandra database 读取数据。我成功地做到了。

现在我已经开始做benchmarking,这意味着从 Cassandra 数据库读取需要多少时间。所以我在下面的代码中添加了我的benchmarking code

现在我不确定我是否在正确的位置添加了benchmarking code 以使用Pelops client 测量Cassandra database 的读取延迟?

下面是我的代码-

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;
}

谁能看一下,让我知道我做得对不对?

【问题讨论】:

    标签: java cassandra pelops


    【解决方案1】:

    是的,没错,您希望计时器在查询之前准确启动,并在查询之后立即停止。

    附带说明一下,您没有对计时器做任何事情,请将其分配给一个变量,以便您以后可以使用它。

    【讨论】:

    • 感谢您的帮助。我假设这条线只有selector.getColumnsFromRow(columnFamily, rowKey, myPredicate, ConsistencyLevel.ONE); 它会从 Cassandra 数据库中获取数据。所以如果我的假设是正确的,我已经把计时器放在了正确的位置。是的,关于计时器,我已经在那个获取持续时间的方法中有一个静态地图,我稍后会使用它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-01
    • 2016-03-02
    • 2019-02-02
    • 1970-01-01
    • 2017-09-18
    • 1970-01-01
    相关资源
    最近更新 更多