问题描述
让我澄清一下
我有一个列族,用UTF8键:apple#NewYork,banana#LosAngeles,banana#NewYork,cherry# ...等等。
我需要的是因为它们被排序,然后我想得到所有的香蕉开始键?
$ b $复合类型如何?
将当前行映射到
row_key => {
banana:a =>愿望,
香蕉:b =>您希望的值,
...
}
复合类型的优点
- 排序时保留类型属性
- 您的组合键是
a:b:c
,您可以查询a,a:b范围内的所有列,也可以查询如a:b:c
现在您可以执行列切片
例如:
row_key => {1:a => 1,1:b => 1。 1,10:bb => 1,1:c => 1。 2}
ColumnSlice(array(1),array(1))=>第一个组件等于1的所有列
ColumnSlice(array(1),array(10))=>所有列的第一个组件在1和10之间
ColumnSlice(,array(1,'c'))=>从第一个组件小于1且第二个组件小于'c'的行开头的所有列
你可以做相反的上述事情,也可以玩包容性&排除限制。
还有一点要记住,你不能直接要求第二个组件范围内的所有列< x跳过第一个
偶数行键支持复合类型,但是如果你使用随机分区器,那就没有意义了。
Let me clarify it
I have a Column Family, with UTF8 keys like that :apple#NewYork, banana#LosAngeles, banana#NewYork, cherry#NewYork, ... and so on
I need that because they are sorted, and then I would like to get all 'banana' starting keys?
Is it possible or is there a workaround?
How about composite types?
Map your current rows to columns like
row_key => { banana:a => "value you wish", banana:b => "value you wish", ...}
Advantages of composite types are
- They preserve type property while sorting
- Incase your composite key is
a:b:c
you can query for all columns in the range of a, a:b and also point queries like a:b:c
Now you can perform Column Slice for example using phpcassa Ex:
row_key => { 1:a => 1, 1:b => 1, 10:bb => 1, 1:c => 2}
ColumnSlice(array(1), array(1)) => All Columns with first component equal to 1
ColumnSlice(array(1), array(10)) => All Columns with first component between 1 and 10
ColumnSlice("", array(1, 'c')) => All Columns from the beginning of row whose first component less than 1 and second component less than 'c'
You can do the above said things in reverse and can also play with inclusive & exclusive limits.
Also one point to remember, You can't directly ask for all columns in the range of second component < x skipping the first one
Even row keys support composite types but in case you are using random partitioner then it makes no sense.
这篇关于Cassandra rangequery,知道开始键的开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!