在处理数据需要在 UUID 上排序的用例时,这些数据都是类型 1 或基于时间并使用 Datastax Cassandra Java 驱动程序库 (UUIDS.timebased()) 生成的,我发现 UUID.compareTo 没有对某些数据进行排序UUID 正确。compareTo 中的逻辑是
/**
* Compares this UUID with the specified UUID.
*
* <p> The first of two UUIDs is greater than the second if the most
* significant field in which the UUIDs differ is greater for the first
* UUID.
*
* @param val
* {@code UUID} to which this {@code UUID} is to be compared
*
* @return -1, 0 or 1 as this …Run Code Online (Sandbox Code Playgroud)