带有CQL 3的动态列

时间:2016-05-16 17:36:18

标签: cassandra cql

我阅读了有关存储时间序列数据https://academy.datastax.com/resources/getting-started-time-series-data-modeling

的Datastax文章

根据文章,它应该创建用于存储一些时间序列的宽行。像这样(文章图片): enter image description here 我创建了表:

CREATE TABLE test.times ( id text, time timestamp, temperature text, PRIMARY KEY (id, time));

并插入一些值:

cqlsh> insert into test.times (id, time , temperature ) VALUES ( '1', '2013-04-03 07:03:00', '72F');
cqlsh> insert into test.times (id, time , temperature ) VALUES ( '1', '2013-04-03 07:03:01', '73F');
cqlsh> insert into test.times (id, time , temperature ) VALUES ( '1', '2013-04-03 07:03:02', '74F');
cqlsh> insert into test.times (id, time , temperature ) VALUES ( '2', '2013-04-03 07:04:02', '74F');
cqlsh> insert into test.times (id, time , temperature ) VALUES ( '2', '2013-04-03 07:04:03', '72F');

我使用sstabledump工具转储了我的时间表。然后我得到了下一个转储:

[
  {
    "partition" : {
      "key" : [ "2" ],
      "position" : 0
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 15,
        "clustering" : [ "2013-04-03 07:04+0200" ],
        "liveness_info" : { "tstamp" : 1463419324694096 },
        "cells" : [
          { "name" : "temperature", "value" : "74F" }
        ]
      },
      {
        "type" : "row",
        "position" : 36,
        "clustering" : [ "2013-04-03 07:04+0200" ],
        "liveness_info" : { "tstamp" : 1463419332655070 },
        "cells" : [
          { "name" : "temperature", "value" : "72F" }
        ]
      }
    ]
  },
  {
    "partition" : {
      "key" : [ "1" ],
      "position" : 58
    },
    "rows" : [
      {
        "type" : "row",
        "position" : 73,
        "clustering" : [ "2013-04-03 07:03+0200" ],
        "liveness_info" : { "tstamp" : 1463419298628467 },
        "cells" : [
          { "name" : "temperature", "value" : "72F" }
        ]
      },
      {
        "type" : "row",
        "position" : 91,
        "clustering" : [ "2013-04-03 07:03+0200" ],
        "liveness_info" : { "tstamp" : 1463419310835537 },
        "cells" : [
          { "name" : "temperature", "value" : "73F" }
        ]
      },
      {
        "type" : "row",
        "position" : 112,
        "clustering" : [ "2013-04-03 07:03+0200" ],
        "liveness_info" : { "tstamp" : 1463419317481809 },
        "cells" : [
          { "name" : "temperature", "value" : "74F" }
        ]
      }
    ]
  }
]

我看到C *为每个新条目创建了新行。我做错了什么?如何使用CQL创建宽行?

Cassandra v.3.5

1 个答案:

答案 0 :(得分:3)

你做得对。 宽行实际上意味着一个宽分区。您会看到包含多个逻辑id分区(由cql rows标识)。这些分区是你想要的广泛。

C * 3.0存储引擎的链接

  1. http://thelastpickle.com/blog/2016/03/04/introductiont-to-the-apache-cassandra-3-storage-engine.html

  2. http://www.datastax.com/2015/12/storage-engine-30