Cassandra / Pycassa:获取随机行 [英] Cassandra/Pycassa: Getting random rows

查看:149
本文介绍了Cassandra / Pycassa:获取随机行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能从Cassandra检索随机行(使用Python / Pycassa)?



更新:随机行我的意思是随机的<

您可以通过创建一个 get_range 来执行此操作。 c $ c>开始键(只是一个随机字符串)和 row_count / p>

从内存中,我认为完成键需要与 / code>,以便查询'wrap around'的键空间;这通常会返回所有行,但 row_count 会限制。



Haven 't尝试,但这应该确保你得到一个单一的结果,而不必知道确切的行键。


Is there a possibility to retrieve random rows from Cassandra (using it with Python/Pycassa)?

Update: With random rows I mean randomly selected rows!

解决方案

You might be able to do this by making a get_range request with a random start key (just a random string), and a row_count of 1.

From memory, I think the finish key would need to be the same as start, so that the query 'wraps around' the keyspace; this would normally return all rows, but the row_count will limit that.

Haven't tried it but this should ensure you get a single result without having to know exact row keys.

这篇关于Cassandra / Pycassa:获取随机行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆