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 卡桑德拉复合型_Nosql_Cassandra_Hector - Fatal编程技术网

Nosql 卡桑德拉复合型

Nosql 卡桑德拉复合型,nosql,cassandra,hector,Nosql,Cassandra,Hector,我在Hector和Cassandra的教程中看到了DynamicCompositeType 有人能详细说明这两者的区别吗 create column family Composite with comparator ='DynamicCompositeType (t=>TimeUUIDType,s=>UTF8Type)' and default_validation_class=UTF8Type and key_validation_class=UT

我在Hector和Cassandra的教程中看到了
DynamicCompositeType

有人能详细说明这两者的区别吗

   create column family Composite with comparator ='DynamicCompositeType
       (t=>TimeUUIDType,s=>UTF8Type)'
       and default_validation_class=UTF8Type and key_validation_class=UTF8Type;


我没有在Cassandra文档中找到它,在静态复合CF中,每一列都有相同的类型,而在动态CCF中,每一列都可以有不同的数据类型


如果您确定CF中包含的数据类型,最好使用静态定义,否则请使用动态CF。

这可能有助于了解Cassandra如何存储数据以及组合实际上是什么:

  • 所有数据,无论您使用哪个验证器/比较器,都存储为字节。当您指定验证器时,您只是要求Cassandra确保这些字节按照您的意愿进行编码。相比之下,比较器只是根据特定于给定编码的自然顺序对列进行排序

  • 因此,组合只是具有特定编码的字节数组。这种编码非常简单:对于每个组件,它存储一个两字节的长度,后跟字节编码的组件,后跟一个终止位,用于确定它是包含的还是独占的。因为任何东西都可以存储在字节数组中,所以您可以拥有不同的组件类型——但您必须知道它们是什么,并自己对它们进行解码/编码

  • 为了实现动态复合,Hector将额外的类型数据写入字节数组,以便在读取字节时知道如何解码。静态复合材料无法做到这一点,因为没有类型信息

create column family Composite
    with comparator = 'CompositeType(TimeUUIDType,UTF8Type)' 
    and key_validation_class = 'UTF8Type' 
    and default_validation_class = 'UTF8Type'