DELETE存储在特定节点上的行 [英] DELETE rows stored on a particular node
问题描述
我如何写一个CQL 3 DELETE
行规范( WHERE
它将只选择存储在给定节点上的行?如果不可能,是否有 SELECT
关系( WHERE
指示哪些行存储在特定节点上?
我想这样做,因此我可以在每个数据存储节点上运行一个管理守护进程(在Java中)从该节点删除旧记录,因此可以确保其节点不会耗尽磁盘空间。因为我在写一个守护进程,而不是执行一次性清理,不适合使用 nodetool
程序查询存储在节点上的令牌范围。 / p>
这里有一种方法可行(但是下面有更好的想法)。如果您没有启用vnode,您可以标识令牌范围(从 nodetool ring
命令),然后将其用作delete命令的一部分。例如:
从MyTable中删除其中
令牌(MyPK)> = Token1和
令牌MyPK) Token2和
(这里你的删除逻辑)
;但是,一个更简单和更安全的方法是让Cassandra知道数据在哪里,然后,只需从任何节点执行此操作: 从MyTable中删除其中
;
How can I write a CQL 3 DELETE
row specification (WHERE
clause) that will select only rows that are stored on a given node? If that is not possible, is there a SELECT
relation (WHERE
clause) that will indicate which rows are stored on a particular node?
I want to do this so I can have a housekeeping daemon (in Java) running on each data-store node, which deletes old records from that node, so it can ensure that its node does not run out of disk space. As I am writing a daemon, rather than performing a one-off cleanup, it is not appropriate to use the nodetool
program to query for the token ranges stored on a node.
解决方案 Here's one way that might work (but see below for a better idea). If you don't have vnodes enabled, you could identify the token ranges (from then nodetool ring
command), then use them as part of your delete command. For example:
delete from MyTable where
token(MyPK) >= Token1 and
token(MyPK) < Token2 and
(your delete logic here)
;
However, a much simpler and safer method would be to just let Cassandra figure out where the data is, and just do this from any node:
delete from MyTable where
(your delete logic here)
;
这篇关于DELETE存储在特定节点上的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!