我正在尝试创建一个超级列系列,它将复制这样的结构.
{ 'hd': '2008/12/12 10:03': { metric1: 'blah',metric2: 'blah'} '2008/12/2 9:03': { metric1: 'blah',metric2: 'blah'} 'cpu': '2008/12/12 10:03': { metric1: 'blah',metric2: 'blah'} }
我目前的尝试看起来像这样:
create column family Timestep with column_type = 'Super' and comparator = 'AsciiType' and subcomparator = 'DateType' and default_validation_class = 'DoubleType' and key_validation_class = 'AsciiType' and column_metadata = [ {column_name : metric1,validation_class : DoubleType} {column_name : metric2,validation_class : DoubleType} ];
但是,如果我尝试在cassandra-cli中运行以上内容:
java.lang.RuntimeException: org.apache.cassandra.db.marshal.MarshalException: unable to coerce 'open' to a formatted date (long)
也许我不理解超级列系列是什么,但任何帮助都会很棒.
谢谢.
解决方法
强烈建议您不要使用超级列,尤其是在新设计中.它们从来没有出现过问题,现在它们已被弃用,并且更有效地被复合键所取代.
您可以在CQL 3中很好地表示您的数据,例如:
CREATE TABLE Timestep ( hardware ascii,when timestamp,metric1 double,metric2 double,PRIMARY KEY (hardware,when) );
或者,根据您预期的具体情况,使用它可能更有意义:
CREATE TABLE Timestep ( hardware ascii,metricname ascii,value double,metricname,when) ) WITH COMPACT STORAGE;
有关这些如何在Cassandra中转换为存储引擎范围行的更多信息,请参见this article.