cassandra中列的默认排序顺序? [英] default sorting order of columns in cassandra?
问题描述
我正在阅读本教程,其中讲师说连续的列的默认顺序为 UTF8-tye
。但是他不作进一步探讨。
I was going through the tutorial where the instructor says that the default ordering of columns with in a row is UTF8-tye
. But he does not touch upon it further.
我不明白这是什么意思。特别是如果我的列是不同的类型,例如 int
, timestamp
等,会怎样?
I don't understand what it means. especially what if my columns are different types such as int
, timestamp
etc.
我还要如何将列的排序顺序指定为 UTF8类型以外的其他内容。
Also how would I specify the sort order on the columns to be something other than "UTF8-type".
推荐答案
他在谈论的是列名,而不是列值。
在旧的cassandra版本中,您可以使用SuperColumns,它们是行中列的集合。像这样的东西:
He is talking about the columns names, not the columns values. In old cassandra versions you could use SuperColumns, which are collections of columns within a Row. Something like this:
{ RowKey:
{ SuperColumn1Key: {c1:v, c2:v .... } },
{ SuperColumn2Key: {c1:v, c2:v .... } },
{ SuperColumn3Key: {c1:v, c2:v .... } }
}
这与今天的情况很相似。比较器既可以建立行中的超级列排序,也可以根据名称对列进行排序(您可以在SuperColumnFamily中选择两个不同的比较器,一个用于超级列排序,另一个用于列排序)。例如,将TimeUUID比较器用于超级列,您可以按时间检索它们,而UTF8Type是字母排序。
It is something similar to what today is a wide row. The comparator could establish both the sorting of supercolumns within a row and also sorting of columns by their name (you could choose two differents comparator in a SuperColumnFamily, one for supercolumns sorting and another for columns sorting). For example using TimeUUID comparator for supercolumns you could retrieve them sorted by time while UTF8Type is an "alphabetic" sorting.
想象一下UTF8列比较器中的这一行:
Imagine this row in an UTF8 Columns Comparator:
{ id: {"author":"john", "vote": 3} }
现在让我们添加一个新列,说文字。由于是utf8,因此文字( a << t> v)将位于作者和投票之间
Now let's add a new column, say text. Since it's utf8, "text" ("a"<"t"<"v") will be between author and vote
{ id: {"author":"john", "text": "blablabla", "vote": 3} }
不过,我认为您看到的是旧视频,因为在新版本中不再使用此概念
However I think what you've seen is an old video, since this concept is not used anymore in newer version
HTH,Carlo
HTH, Carlo
这篇关于cassandra中列的默认排序顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!