2016-05-16 72 views
0

動態列我讀到存儲時序數據https://academy.datastax.com/resources/getting-started-time-series-data-modeling與CQL 3

根據文章應該儲存一些時間序列創建寬行Datastax文章。像這樣(PIC從文章): 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

回答

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

+0

是否排在CQL一樣節儉列? – Cortwave

+0

有點兒,這個問題在存儲系統被重寫的C * 3.0中並不真正相關。以前,您可以將'cql row'想象爲一組相鄰的單元格,每個單元格都具有集羣鍵值,因爲它是「標題」,並且具有不同非主鍵列的值,因爲它是值。 請參閱http://stackoverflow.com/questions/20512710/cassandra-has-a-limit-of-2-billion-cells-per-partition-but-whats-a-partition/20525076#20525076 隨着新的存儲格式,但實際上不再有Thrift等價物。 – RussS

+0

非常感謝!你可以建議一些關於C * 3.x中數據存儲模型的文章嗎? – Cortwave