Cassandra:柱系列与超级柱系列 [英] Cassandra: Column Family vs Super Column Family

查看:366
本文介绍了Cassandra:柱系列与超级柱系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要我需要我的数据库来存储以下数据:

I have a requirement where i need my database to store the following data:

- For each build, store the results of 3 performance runs. The result includes tps and latency. 

在cassandra数据模型上读取,这直接映射到以下格式的超级列族: / p>

Reading up on cassandra data model, this directly maps to a super column family of the following format:

BenchmarkSuperColumnFamily= {

build_1: {
   Run1: {1000K, 0.5ms}
   Run2: {1000K, 0.5ms}
   Run3: {1000K, 0.5ms}
}

build_2: {
   Run1: {1000K, 0.5ms}
   Run2: {1000K, 0.5ms}
   Run3: {1000K, 0.5ms}
}
...

}

但是,我阅读下面的回答不推荐使用Super Column系列。我想知道是否有一个更好的方式为我的需求创建一个模型。

But, i read in the following answer that the use of Super Column family is discouraged. I wanted to know if there is a better way of creating a model for my requirement.

PS,我从以下<借阅JSONish记法文章

推荐答案

链接到的StackOverflow答案是正确的。您不应在新应用程序中使用SuperColumns。它们的存在是为了向后兼容。

The StackOverflow answer that you linked to is correct. You shouldn't be using SuperColumns in new applications. They exist for backwards compatibility however.

一般来说,复合列可以用来模拟由超级列提供的任何模型。基本上,它们允许您将列名称分为多个部分。因此,如果你指定一个CompositeType(UTF8Type,UTF8Type)的比较器,你的数据模型结束看起来像这样:

In general, composite columns can be used to mimic any model provided by super columns. Basically, they allow you to separate your column names into multiple parts. So if you were to specify a comparator of 'CompositeType(UTF8Type, UTF8Type)', your data model wound end up looking like this:

BenchmarkColumnFamily= {

   build_1: {
       (Run1, TPS) : 1000K
       (Run1, Latency) : 0.5ms
       (Run2, TPS) : 1000K
       (Run2, Latency) : 0.5ms
       (Run3, TPS) : 1000K
       (Run3, Latency) : 0.5ms
    }

    build_2: {
       ...
    }
...

}

$ b b

对于上述模型,您可以使用单个查询来获取单个运行的单个数据点,单个运行的所有数据点或多个运行的所有数据点。

With the above model you could use a single query to get a single data point for a single run, all data points for a single run, or all data points for multiple runs.

有关复合列的详细信息:
http://www.datastax.com/dev/blog/introduction-to-composite-columns-part-1

More info on composite columns: http://www.datastax.com/dev/blog/introduction-to-composite-columns-part-1

这篇关于Cassandra:柱系列与超级柱系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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