Discussion:
Highest and lowest valid values for UUIDs/TimeUUIDs
Drew Kutcharian
2012-04-24 06:46:38 UTC
Permalink
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))));
}
Tyler Hobbs
2012-04-24 12:44:29 UTC
Permalink
At least for TimeUUIDs, this email I sent to client-dev@ a couple of weeks
ago should help to explain things:
http://www.mail-archive.com/client-***@cassandra.apache.org/msg00125.html

Looking at the linked pycassa code might be the most useful thing.
Post by Drew Kutcharian
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
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
0))));
}
--
Tyler Hobbs
DataStax <http://datastax.com/>
Drew Kutcharian
2012-04-24 17:08:06 UTC
Permalink
Thanks Tyler. So have you actually tried this with Cassandra?
Post by Tyler Hobbs
Looking at the linked pycassa code might be the most useful thing.
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
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
0))));
}
--
Tyler Hobbs
DataStax
Tyler Hobbs
2012-04-24 17:15:38 UTC
Permalink
Yes, I have tested it.
Post by Drew Kutcharian
Thanks Tyler. So have you actually tried this with Cassandra?
Looking at the linked pycassa code might be the most useful thing.
Post by Drew Kutcharian
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
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
0))));
}
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Tyler Hobbs
DataStax <http://datastax.com/>
Drew Kutcharian
2012-04-24 17:47:59 UTC
Permalink
Thanks. So looking at the code, to get the lowest possible TimeUUID value using your function I should just call convert_time_to_uuid(0) ?
Post by Tyler Hobbs
Yes, I have tested it.
Thanks Tyler. So have you actually tried this with Cassandra?
Post by Tyler Hobbs
Looking at the linked pycassa code might be the most useful thing.
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
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
0))));
}
--
Tyler Hobbs
DataStax
--
Tyler Hobbs
DataStax
Tyler Hobbs
2012-04-24 18:21:59 UTC
Permalink
Oh, I just realized that you're asking about the lowest TimeUUID *overall*,
not just for a particular timestamp. Sorry.

The lowest possible TimeUUID is '00000000-0000-1000-8080-808080808080'.
The highest is 'ffffffff-ffff-1fff-bf7f-7f7f7f7f7f7f'.
Post by Drew Kutcharian
Thanks. So looking at the code, to get the lowest possible TimeUUID value
using your function I should just call convert_time_to_uuid(0) ?
Yes, I have tested it.
Post by Drew Kutcharian
Thanks Tyler. So have you actually tried this with Cassandra?
Looking at the linked pycassa code might be the most useful thing.
Post by Drew Kutcharian
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
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
0))));
}
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Tyler Hobbs
DataStax <http://datastax.com/>
Drew Kutcharian
2012-04-24 18:56:29 UTC
Permalink
Nice, that's exactly what I was looking for.
Oh, I just realized that you're asking about the lowest TimeUUID *overall*, not just for a particular timestamp. Sorry.
The lowest possible TimeUUID is '00000000-0000-1000-8080-808080808080'.
The highest is 'ffffffff-ffff-1fff-bf7f-7f7f7f7f7f7f'.
Thanks. So looking at the code, to get the lowest possible TimeUUID value using your function I should just call convert_time_to_uuid(0) ?
Post by Tyler Hobbs
Yes, I have tested it.
Thanks Tyler. So have you actually tried this with Cassandra?
Post by Tyler Hobbs
Looking at the linked pycassa code might be the most useful thing.
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
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
0))));
}
--
Tyler Hobbs
DataStax
--
Tyler Hobbs
DataStax
--
Tyler Hobbs
DataStax
Carlo Pires
2012-04-25 12:11:11 UTC
Permalink
Tyler,

A think you could add this values as python constants to pycassa. This
would be very useful for many people.
Post by Drew Kutcharian
Nice, that's exactly what I was looking for.
Oh, I just realized that you're asking about the lowest TimeUUID
*overall*, not just for a particular timestamp. Sorry.
The lowest possible TimeUUID is '00000000-0000-1000-8080-808080808080'.
The highest is 'ffffffff-ffff-1fff-bf7f-7f7f7f7f7f7f'.
Post by Drew Kutcharian
Thanks. So looking at the code, to get the lowest possible TimeUUID value
using your function I should just call convert_time_to_uuid(0) ?
Yes, I have tested it.
Post by Drew Kutcharian
Thanks Tyler. So have you actually tried this with Cassandra?
Looking at the linked pycassa code might be the most useful thing.
Post by Drew Kutcharian
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
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
0))));
}
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Carlo Pires
62 8209-1444 TIM
62 3251-1383
Skype: carlopires
Tyler Hobbs
2012-04-25 18:09:22 UTC
Permalink
Good idea. Done here:
https://github.com/pycassa/pycassa/commit/2390363066c7efd79bdd2f27cd2d4496f692abf4
Post by Carlo Pires
Tyler,
A think you could add this values as python constants to pycassa. This
would be very useful for many people.
Post by Drew Kutcharian
Nice, that's exactly what I was looking for.
Oh, I just realized that you're asking about the lowest TimeUUID
*overall*, not just for a particular timestamp. Sorry.
The lowest possible TimeUUID is '00000000-0000-1000-8080-808080808080'.
The highest is 'ffffffff-ffff-1fff-bf7f-7f7f7f7f7f7f'.
Post by Drew Kutcharian
Thanks. So looking at the code, to get the lowest possible TimeUUID
value using your function I should just call convert_time_to_uuid(0) ?
Yes, I have tested it.
Post by Drew Kutcharian
Thanks Tyler. So have you actually tried this with Cassandra?
Looking at the linked pycassa code might be the most useful thing.
Post by Drew Kutcharian
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
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
0))));
}
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Tyler Hobbs
DataStax <http://datastax.com/>
--
Carlo Pires
62 8209-1444 TIM
62 3251-1383
Skype: carlopires
--
Tyler Hobbs
DataStax <http://datastax.com/>
Loading...