You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Drew Kutcharian <dr...@venarc.com> on 2012/04/24 08:46:38 UTC
Highest and lowest valid values for UUIDs/TimeUUIDs
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))));
}
Re: Highest and lowest valid values for UUIDs/TimeUUIDs
Posted by Tyler Hobbs <ty...@datastax.com>.
Good idea. Done here:
https://github.com/pycassa/pycassa/commit/2390363066c7efd79bdd2f27cd2d4496f692abf4
On Wed, Apr 25, 2012 at 7:11 AM, Carlo Pires <ca...@gmail.com> wrote:
> Tyler,
>
> A think you could add this values as python constants to pycassa. This
> would be very useful for many people.
>
>
> 2012/4/24 Drew Kutcharian <dr...@venarc.com>
>
>> Nice, that's exactly what I was looking for.
>>
>>
>> On Apr 24, 2012, at 11:21 AM, Tyler Hobbs wrote:
>>
>> 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'.
>>
>> On Tue, Apr 24, 2012 at 12:47 PM, Drew Kutcharian <dr...@venarc.com>wrote:
>>
>>> 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) ?
>>>
>>>
>>> On Apr 24, 2012, at 10:15 AM, Tyler Hobbs wrote:
>>>
>>> Yes, I have tested it.
>>>
>>> On Tue, Apr 24, 2012 at 12:08 PM, Drew Kutcharian <dr...@venarc.com>wrote:
>>>
>>>> Thanks Tyler. So have you actually tried this with Cassandra?
>>>>
>>>>
>>>>
>>>> On Apr 24, 2012, at 5:44 AM, Tyler Hobbs wrote:
>>>>
>>>> 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-dev@cassandra.apache.org/msg00125.html
>>>>
>>>> Looking at the linked pycassa code might be the most useful thing.
>>>>
>>>> On Tue, Apr 24, 2012 at 1:46 AM, Drew Kutcharian <dr...@venarc.com>wrote:
>>>>
>>>>> 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
>>>> 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/>
Re: Highest and lowest valid values for UUIDs/TimeUUIDs
Posted by Carlo Pires <ca...@gmail.com>.
Tyler,
A think you could add this values as python constants to pycassa. This
would be very useful for many people.
2012/4/24 Drew Kutcharian <dr...@venarc.com>
> Nice, that's exactly what I was looking for.
>
>
> On Apr 24, 2012, at 11:21 AM, Tyler Hobbs wrote:
>
> 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'.
>
> On Tue, Apr 24, 2012 at 12:47 PM, Drew Kutcharian <dr...@venarc.com> wrote:
>
>> 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) ?
>>
>>
>> On Apr 24, 2012, at 10:15 AM, Tyler Hobbs wrote:
>>
>> Yes, I have tested it.
>>
>> On Tue, Apr 24, 2012 at 12:08 PM, Drew Kutcharian <dr...@venarc.com>wrote:
>>
>>> Thanks Tyler. So have you actually tried this with Cassandra?
>>>
>>>
>>>
>>> On Apr 24, 2012, at 5:44 AM, Tyler Hobbs wrote:
>>>
>>> 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-dev@cassandra.apache.org/msg00125.html
>>>
>>> Looking at the linked pycassa code might be the most useful thing.
>>>
>>> On Tue, Apr 24, 2012 at 1:46 AM, Drew Kutcharian <dr...@venarc.com>wrote:
>>>
>>>> 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
>>> 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
Re: Highest and lowest valid values for UUIDs/TimeUUIDs
Posted by Drew Kutcharian <dr...@venarc.com>.
Nice, that's exactly what I was looking for.
On Apr 24, 2012, at 11:21 AM, Tyler Hobbs wrote:
> 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'.
>
> On Tue, Apr 24, 2012 at 12:47 PM, Drew Kutcharian <dr...@venarc.com> wrote:
> 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) ?
>
>
> On Apr 24, 2012, at 10:15 AM, Tyler Hobbs wrote:
>
>> Yes, I have tested it.
>>
>> On Tue, Apr 24, 2012 at 12:08 PM, Drew Kutcharian <dr...@venarc.com> wrote:
>> Thanks Tyler. So have you actually tried this with Cassandra?
>>
>>
>>
>> On Apr 24, 2012, at 5:44 AM, Tyler Hobbs wrote:
>>
>>> 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-dev@cassandra.apache.org/msg00125.html
>>>
>>> Looking at the linked pycassa code might be the most useful thing.
>>>
>>> On Tue, Apr 24, 2012 at 1:46 AM, Drew Kutcharian <dr...@venarc.com> wrote:
>>> 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
>>> DataStax
>>>
>>
>>
>>
>>
>> --
>> Tyler Hobbs
>> DataStax
>>
>
>
>
>
> --
> Tyler Hobbs
> DataStax
>
Re: Highest and lowest valid values for UUIDs/TimeUUIDs
Posted by Tyler Hobbs <ty...@datastax.com>.
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'.
On Tue, Apr 24, 2012 at 12:47 PM, Drew Kutcharian <dr...@venarc.com> wrote:
> 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) ?
>
>
> On Apr 24, 2012, at 10:15 AM, Tyler Hobbs wrote:
>
> Yes, I have tested it.
>
> On Tue, Apr 24, 2012 at 12:08 PM, Drew Kutcharian <dr...@venarc.com> wrote:
>
>> Thanks Tyler. So have you actually tried this with Cassandra?
>>
>>
>>
>> On Apr 24, 2012, at 5:44 AM, Tyler Hobbs wrote:
>>
>> 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-dev@cassandra.apache.org/msg00125.html
>>
>> Looking at the linked pycassa code might be the most useful thing.
>>
>> On Tue, Apr 24, 2012 at 1:46 AM, Drew Kutcharian <dr...@venarc.com> wrote:
>>
>>> 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
>> DataStax <http://datastax.com/>
>>
>>
>>
>
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>
>
>
--
Tyler Hobbs
DataStax <http://datastax.com/>
Re: Highest and lowest valid values for UUIDs/TimeUUIDs
Posted by Drew Kutcharian <dr...@venarc.com>.
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) ?
On Apr 24, 2012, at 10:15 AM, Tyler Hobbs wrote:
> Yes, I have tested it.
>
> On Tue, Apr 24, 2012 at 12:08 PM, Drew Kutcharian <dr...@venarc.com> wrote:
> Thanks Tyler. So have you actually tried this with Cassandra?
>
>
>
> On Apr 24, 2012, at 5:44 AM, Tyler Hobbs wrote:
>
>> 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-dev@cassandra.apache.org/msg00125.html
>>
>> Looking at the linked pycassa code might be the most useful thing.
>>
>> On Tue, Apr 24, 2012 at 1:46 AM, Drew Kutcharian <dr...@venarc.com> wrote:
>> 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
>> DataStax
>>
>
>
>
>
> --
> Tyler Hobbs
> DataStax
>
Re: Highest and lowest valid values for UUIDs/TimeUUIDs
Posted by Tyler Hobbs <ty...@datastax.com>.
Yes, I have tested it.
On Tue, Apr 24, 2012 at 12:08 PM, Drew Kutcharian <dr...@venarc.com> wrote:
> Thanks Tyler. So have you actually tried this with Cassandra?
>
>
>
> On Apr 24, 2012, at 5:44 AM, Tyler Hobbs wrote:
>
> 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-dev@cassandra.apache.org/msg00125.html
>
> Looking at the linked pycassa code might be the most useful thing.
>
> On Tue, Apr 24, 2012 at 1:46 AM, Drew Kutcharian <dr...@venarc.com> wrote:
>
>> 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
> DataStax <http://datastax.com/>
>
>
>
--
Tyler Hobbs
DataStax <http://datastax.com/>
Re: Highest and lowest valid values for UUIDs/TimeUUIDs
Posted by Drew Kutcharian <dr...@venarc.com>.
Thanks Tyler. So have you actually tried this with Cassandra?
On Apr 24, 2012, at 5:44 AM, Tyler Hobbs wrote:
> 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-dev@cassandra.apache.org/msg00125.html
>
> Looking at the linked pycassa code might be the most useful thing.
>
> On Tue, Apr 24, 2012 at 1:46 AM, Drew Kutcharian <dr...@venarc.com> wrote:
> 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
> DataStax
>
Re: Highest and lowest valid values for UUIDs/TimeUUIDs
Posted by Tyler Hobbs <ty...@datastax.com>.
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-dev@cassandra.apache.org/msg00125.html
Looking at the linked pycassa code might be the most useful thing.
On Tue, Apr 24, 2012 at 1:46 AM, Drew Kutcharian <dr...@venarc.com> wrote:
> 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
DataStax <http://datastax.com/>