将相同的行两次添加到cassandra列族有什么影响?

时间:2013-06-05 17:08:03

标签: schema cassandra command-line-interface

我可以根据需要多次运行此更新。即如果行'test'已经存在,代码不会出错:

[default@testdata] update column family my_column_family with
...         column_metadata =
...         [
...         {column_name: test, validation_class: UTF8Type}
... ];
f20046d1-0f89-3c52-b568-c41061e32071
Waiting for schema agreement...
... schemas agree across the cluster
[default@testdata] update column family my_column_family with
...         column_metadata =
...         [
...         {column_name: test, validation_class: UTF8Type}
... ];
299eebb0-3c71-378d-b9cd-972bb35a49e0
Waiting for schema agreement...
... schemas agree across the cluster

此外,更新不会删除该行中的任何现有数据。

我的问题:多次添加同一行会产生我应该知道的次要影响吗?我相信除非再次指定,否则会在更新时删除索引,但我不担心这一点。

我不希望更新以高速率运行。可能每天都会这样,但是列系列可能包含数百万条记录。

1 个答案:

答案 0 :(得分:1)

简短的回答:使用CQL,它会更有意义。 http://www.datastax.com/docs/1.2/ddl/table

更长的答案:设置Thrift column_metadata将根据需要删除或创建索引,以使Cassandra的内部架构与您要更新的内容相匹配。它不会让您将列类型更改为不兼容的类型,但您可以通过删除定义并重新添加它来“欺骗”它。

注意:如果您每天都在更改架构,那么无论您使用的是CQL还是Thrift,都会出错。