如何在集群环境中使用 cassandra 时间戳生成 UUID(Long)?

How to generate UUID(Long) using cassandra timestamp in cluster environment?

我有这样的要求,我们需要根据集群中的 Cassandra 时间戳使用 Java 生成 UUID 作为 Long 值。任何人都可以帮助如何使用 java 和 cassandra 集群时间戳组合来生成它吗?

使用 TimeUUID cql3 数据类型:

A value of the timeuuid type is a Type 1 UUID. A type 1 UUID includes the time of its generation and are sorted by timestamp, making them ideal for use in applications requiring conflict-free timestamps. For example, you can use this type to identify a column (such as a blog entry) by its timestamp and allow multiple clients to write to the same partition key simultaneously. Collisions that would potentially overwrite data that was not intended to be overwritten cannot occur.

在 Java 中,您可以使用来自 com.datastax.driver.core.utils.UUIDs:

UUIDs 助手 class
UUIDs.timeBased()