Drew Kutcharian
2012-04-24 06:46:38 UTC
Hi All,
Considering that UUIDs are compared as numbers in Java [1], what are the lowest and highest possible values a valid UUID can have? How about TimeUUIDs?
The reason I ask is that I would like to pick a "default" UUID value in a composite column definition like Composite(UUID1, UUID2) where UUID1 can be set to the default value if not supplied. In addition, it'd be nice if the "default" columns are always sorted before the rest of the columns.
I was thinking of just doing "new UUID(Long.MAX_VALUE, Long.MAX_VALUE)" or "new UUID(Long.MIN_VALUE, Long.MIN_VALUE)" but not sure if that's going to cause other issues that I'm not aware of.
Thanks,
Drew
[1] Here's the compareTo of java.util.UUID as a reference:
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
return (this.mostSigBits < val.mostSigBits ? -1 :
(this.mostSigBits > val.mostSigBits ? 1 :
(this.leastSigBits < val.leastSigBits ? -1 :
(this.leastSigBits > val.leastSigBits ? 1 :
0))));
}
Considering that UUIDs are compared as numbers in Java [1], what are the lowest and highest possible values a valid UUID can have? How about TimeUUIDs?
The reason I ask is that I would like to pick a "default" UUID value in a composite column definition like Composite(UUID1, UUID2) where UUID1 can be set to the default value if not supplied. In addition, it'd be nice if the "default" columns are always sorted before the rest of the columns.
I was thinking of just doing "new UUID(Long.MAX_VALUE, Long.MAX_VALUE)" or "new UUID(Long.MIN_VALUE, Long.MIN_VALUE)" but not sure if that's going to cause other issues that I'm not aware of.
Thanks,
Drew
[1] Here's the compareTo of java.util.UUID as a reference:
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
return (this.mostSigBits < val.mostSigBits ? -1 :
(this.mostSigBits > val.mostSigBits ? 1 :
(this.leastSigBits < val.leastSigBits ? -1 :
(this.leastSigBits > val.leastSigBits ? 1 :
0))));
}