小编bla*_*der的帖子

Java UUID compareTo 对于 Type1 UUID 无法正常工作

在处理数据需要在 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)

java sorting cassandra datastax-java-driver timeuuid

5
推荐指数
1
解决办法
497
查看次数