Cassandra 将 TTL 添加到现有条目

Cassandra add TTL to existing entries

如何更新整个 table 并为每个条目设置 TTL?

当前场景(Cassandra 2.0.11):

table:

CREATE TABLE external_users (
  external_id text,
  type int,
  user_id text,
  PRIMARY KEY (external_id, type)
) 

当前此 table 中有 ~40mio 条目,我想添加一个 TTL,比如说 86 400 秒(1 天)。 使用 USING TTL(86400) 或更新当前条目的新条目没有问题,但我如何为每个已存在的条目应用 ttl?

我的想法是 select 所有数据并用一个小脚本更新每一行。我只是想知道是否有更简单的方法来实现这一点(因为即使进行批量更新,这也需要一段时间并且需要很大的努力)

提前致谢

无法更改 C* 中现有数据的 TTL。 TTL 只是一个内部列属性,它与所有其他列数据一起写入不可变的 SSTable。引自 the docs:

If you want to change the TTL of expiring data, you have to re-insert the data with a new TTL. In Cassandra, the insertion of data is actually an insertion or update operation, depending on whether or not a previous version of the data exists.