用于对所有行进行分页的 Cassandra CQL 方法 [英] Cassandra CQL method for paging through all rows

查看:30
本文介绍了用于对所有行进行分页的 Cassandra CQL 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式检查大型 cassandra 表中的所有行,并希望使用 CQL.我知道我可以用 thrift 来做到这一点,使用 multiget 一次获取 10,000(左右)行,并将最后检索到的密钥交给下一个 multiget 调用.但是我已经查看了关于 CQL select 的所有文档,似乎没有办法做到这一点.我已经将选择限制设置得越来越高,并将超时设置得越来越高以匹配它.

I want to programmatically examine all the rows in a large cassandra table, and was hoping to use CQL. I know I could do this with thrift, getting 10,000 (or so) rows at a time with multiget and handing the last retrieved key into to the next multiget call. But I have looked through all the documentation on CQL select, and there doesn't seem to be a way to do this. I have resorted to setting the select limit higher and higher, and setting the timeout higher and higher to match it.

是否有一种未公开的方法可以将起点提交给 CQL 选择,或者我是否只需要使用 thrift API 分解并重写我的代码?

Is there an undocumented way to hand in a starting point to CQL select, or do I just need to break down and rewrite my code using the thrift API?

推荐答案

结果大于和小于具有非常不直观但有用的行为(至少在 CQL2 中,我还没有检查 CQL3).它实际上比较的是令牌而不是键值.下面是一个例子:

Turns out greater than and less than have a very non-intuitive, but useful, behavior (at least in CQL2, I haven't check CQL3 yet). It actually compares the tokens not the key values. Here is an example:

> create table users (KEY varchar PRIMARY KEY, data varchar);
> insert into users (KEY, 'data') values ('1', 'one');
> insert into users (KEY, 'data') values ('2', 'two');
> insert into users (KEY, 'data') values ('3', 'three');
> insert into users (KEY, 'data') values ('4', 'four');
> select * from users;
   3 | three
   2 |   two
   1 |   one
   4 |  four
> select * from users LIMIT 1;
   3 | three
> select * from users WHERE KEY > '3' LIMIT 1;
   2 |  two
> select * from users WHERE KEY > '2' LIMIT 1;
   1 |  one
> select * from users WHERE KEY > '1' LIMIT 1;
   4 | four

这篇关于用于对所有行进行分页的 Cassandra CQL 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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