使用 CQL 3 的动态列

Dynamic columns with CQL 3

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

根据文章,它应该创建宽行来存储一些时间序列。像这样(文章中的图片): 我创建了 table:

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 工具转储了我的时间 table。我得到了下一个转储:

[
  {
    "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 创建宽行?

卡桑德拉 3.5 版

你做对了。 wide row实际上是指wide partition。您会看到 分区 (由 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