Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nosql 使用cassandra cli创建两个复合列_Nosql_Cassandra - Fatal编程技术网

Nosql 使用cassandra cli创建两个复合列

Nosql 使用cassandra cli创建两个复合列,nosql,cassandra,Nosql,Cassandra,我的列族需要两个组合列,关键数据类型是ByTestType 以下是使用CQL的表格定义: CREATE TABLE stats ( gid blob, period int, tid blob, sum int, uniques blob, PRIMARY KEY(gid, period, tid) ); 我要做的是使用Cassandr

我的列族需要两个组合列,关键数据类型是ByTestType

以下是使用CQL的表格定义:

CREATE TABLE stats (
      gid          blob,
      period       int,
      tid          blob, 
      sum          int,
      uniques      blob,
      PRIMARY KEY(gid, period, tid)
     );
我要做的是使用Cassandra CLI创建列族。这是我的照片

第一种复合材料的结构为:

CompositeType(Int32Type, BytesType, AsciiType)
它将保存一个整数

第二种复合材料的结构为:

CompositeType(Int32Type, BytesType)
并将保持BytesType

create column family stats with comparator = 'CompositeType(Int32Type, BytesType, AsciiType)';
我不知道如何在“创建柱族”命令中定义第二个组合柱


当然,我假设使用CQL创建的表将生成两个复合列。

在cassandra中,一个列族上只能有一个比较器。这意味着在柱族中也只能有一种类型的组合柱。您使用的CQL语句创建的表实际上将使用您提到的第一个复合类型比较器:

CompositeType(Int32Type, BytesType, AsciiType)
这个比较器可以描述您的所有模式,因为在组合的末尾有“AsciiType”组件。列名的此组件将包含文字字符串“sum”或“uniques”,列值将相应地与类型匹配

使用json样式表示法的示例:

<bytes> : {                               # a row key in your stats column family
    (100, <bytes>, "sum") : 100,          # one column in your row
    (100, <bytes>, "uniques") : <bytes>,  
    (200, <bytes>, "sum") : 200,
    (200, <bytes>, "uniques") : <bytes>
}
<bytes> : {                               # another row in the cf
    ...
}
:{#stats列族中的行键
(100,“总和”):100,#行中的一列
(100,“uniques”):,
(200,“总和”):200,
(200,“uniques”):
}
:{#cf中的另一行
...
}