如何按日期范围查询Cassandra

编程入门 行业动态 更新时间:2024-10-26 10:28:53
本文介绍了如何按日期范围查询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定义 wiki.apache/cassandra/API 这是一个很好的起点。此外,您可能会发现本文很有用 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 wiki.apache/cassandra/API This is a good place to start. Also, you might find this article useful www.sodeso.nl/?p=80 In the third part or so he talks about slice ranging his queries and so on.

更多推荐

如何按日期范围查询Cassandra

本文发布于:2023-10-28 23:11:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538039.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按日   Cassandra

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!