0

我可以根据需要多次运行此更新。即,如果“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

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

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

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

4

1 回答 1

1

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

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

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

于 2013-06-05T17:23:10.590 回答