如何按日期范围查询Cassandra [英] How to query Cassandra by date range

查看:1445
本文介绍了如何按日期范围查询Cassandra的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Cassandra ColumnFamily(0.6.4),将有来自用户的新条目。我想查询Cassandra的新条目,以便我可以在另一个系统中处理该数据。

I have a Cassandra ColumnFamily (0.6.4) that will have new entries from users. I'd like to query Cassandra for those new entries so that I can process that data in another system.

我的意思是,我可以使用TimeUUIDType作为键我的条目,然后查询一个KeyRange,以作为startKey或任何lastStartKey开头。这是正确的方法吗?

My sense was that I could use a TimeUUIDType as the key for my entry, and then query on a KeyRange that starts either with "" as the startKey, or whatever the lastStartKey was. Is this the correct method?

get_range_slice如何实际创建一个范围?它不必知道密钥的数据类型吗?在任何地方没有关键字的数据类型的声明。在storage_conf.xml文件中,声明列的类型,但不声明键的类型。键假定是与列相同的类型吗?还是做一些魔法嗅探猜测?

How does get_range_slice actually create a range? Doesn't it have to know the data type of the key? There's no declaration of the data type of the key anywhere. In the storage_conf.xml file, you declare the type of the columns, but not of the keys. Is the key assumed to be of the same type as the columns? Or does it do some magic sniffing to guess?

我还看过参考实现,人们将TimeUUIDType存储在列中。但是,这似乎有规模的问题,因为这个特定的键将变得热,因为每一个变化都必须更新它。

I've also seen reference implementations where people store TimeUUIDType in columns. However, this seems to have scale issues as this particular key would then become "hot" since every change would have to update it.

在这种情况下的任何指针将不胜感激。

Any pointers in this case would be appreciated.

推荐答案

在排序数据时,只有列键很重要。存储的数据不是自动生成的时间戳。 CompareWith属性在这里很重要。如果将CompareWith设置为UTF8Type,那么键将被解释为UTF8Types。如果将CompareWith设置为TimeUUIDType,那么键将自动解释为时间戳。您不必指定数据类型。查看此页面上的SlicePredicate和SliceRange定义 http://wiki.apache.org/cassandra/API 这是一个很好的起点。此外,您可能会发现本文很有用 http://www.sodeso.nl/?p=80 在第三部分,他谈到切片其他查询等。

When sorting data only the column-keys are important. The data stored is of no consequence neither is the auto-generated timestamp. The CompareWith attribute is important here. If you set CompareWith as UTF8Type then the keys will be interpreted as UTF8Types. If you set the CompareWith as TimeUUIDType then the keys are automatically interpreted as timestamps. You do not have to specify the data type. Look at the SlicePredicate and SliceRange definitions on this page http://wiki.apache.org/cassandra/API This is a good place to start. Also, you might find this article useful http://www.sodeso.nl/?p=80 In the third part or so he talks about slice ranging his queries and so on.

这篇关于如何按日期范围查询Cassandra的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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