将同一行添加两次到cassandra列族会产生什么影响?



我可以根据需要多次运行此更新。也就是说,如果行'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

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

我的问题:多次添加同一行是否有我应该知道的次要影响?我相信索引在更新时被删除,除非它被再次指定,但我不担心这个。

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

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

更详细的回答:设置Thrift column_metadata将根据需要删除或创建索引,以使Cassandra的内部模式匹配您告诉它更新到的内容。它不允许您将列类型更改为不兼容的类型,但您可以通过删除定义并重新添加它来"欺骗"它。

注意:如果你每天都在改变你的模式,你做错了,不管你是使用CQL还是Thrift。

最新更新