gpt4 book ai didi

cassandra - Apache Cassandra 从计数器中删除

转载 作者:行者123 更新时间:2023-12-03 23:30:13 24 4
gpt4 key购买 nike

我正在开发一个用于研究 Apache Cassandra 和 Java EE 6 的小型 Web 应用程序。
Cassandra 版本是 1.1.6。

有问题让我发疯...
我创建了一个带有计数器的表(使用 cqlsh v. 3.0.0)

CREATE TABLE test (
author varchar PRIMARY KEY,
tot counter
)

并以这种方式放置一些值:
update test set tot = tot +1 where author = 'myAuthor';

列族完美更新
author   | tot
----------+-----
myAuthor | 1

但是,如果您尝试删除该行然后再次更新(使用相同的键),则什么也不会发生!该表不再更新,我无法弄清楚原因:在我看来,一旦您使用了 key ,您就不能再使用它了。
我在 datasax 文档(http://www.datastax.com/docs/1.1/references/cql/cql_lexicon)中寻找线索,但没有找到解决方案。

有人能帮我吗?
预先感谢

最佳答案

Cassandra 对删除计数器有一些严格的限制。您无法真正删除一个计数器,然后在任何短时间内再次使用它。来自 Cassandra wiki :

Counter removal is intrinsically limited. For instance, if you issue very quickly the sequence "increment, remove, increment" it is possible for the removal to be lost (if for some reason the remove happens to be the last received messages). Hence, removal of counters is provided for definitive removal only, that is when the deleted counter is not increment afterwards. This holds for row deletion too: if you delete a row of counters, incrementing any counter in that row (that existed before the deletion) will result in an undetermined behavior. Note that if you need to reset a counter, one option (that is unfortunately not concurrent safe) could be to read its value and add -value.

关于cassandra - Apache Cassandra 从计数器中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13653681/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com