按创建日期而不是 HBase 中的时间戳删除行

Delete rows by creation date and not by timestamp in HBase

我有一个 HBase table,其中的行有时会更新(它们的时间戳显然也是如此)

我想知道是否有任何内置方法可以根据行的创建日期对行执行 TTL? (所以,如果我用较新的版本更新一行,它不会影响该行的删除时间吗?)

举个例子:2016 年 4 月 20 日将 'row1' 的值设为 'aaa' 在 TTL 为 2 天的 table 'test' 上,然后如果我在第二天执行另一个 'row1' 放置,该行仍将在 22/04/2016 删除(而不是在23/04/2016 就像常规 TTL 功能一样)

如果没有内置方法,用我自己的代码(Java、scala 或其他)执行此操作的好方法是什么?我认为我无法将完整的 table 扫描检索到内存中,是否有任何方法可以延迟加载整个 table?

提前致谢

来自文档:

ColumnFamilies can set a TTL length in seconds, and HBase will automatically delete rows once the expiration time is reached. This applies to all versions of a row - even the current one. The TTL time encoded in the HBase for the row is specified in UTC.

基于此,你可以在CF上设置一个ttl,一旦达到ttl,该行就会被擦除。此行的每次更新都会重置计时器,因此要不重置您需要使用相同时间戳覆盖最后一次写入的行。