CQL方法用于遍历所有行

CQL方法用于遍历所有行

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

问题描述

我想以编程方式检查大型cassandra表中的所有行,并希望使用CQL。我知道我可以做到这一点与thrift,一次获得10,000(或大约)行与multiget,并把最后检索的密钥进入下一个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,I还没有检查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方法用于遍历所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 16:05