On Sun, Apr 25, 2010 at 5:43 PM, Jonathan Ellis <jbel...@gmail.com> wrote:
> On Sun, Apr 25, 2010 at 5:40 PM, Tatu Saloranta <tsalora...@gmail.com> wrote:
>>> Now with TimeUUIDType, if two UUID have the same timestamps, they are 
>>> ordered
>>> by bytes order.
>>
>> Naively for the whole UUID? That would not be good, given that
>> timestamp within UUID is not stored in expected lexical order, but
>> with sort of little-endian mess (first bytes are least-significant
>> bytes of timestamp).
>
> I think the code here is clearer than explaining in English. :)
>
> comparing timeuuids o1 and o2:
>
>        long t1 = LexicalUUIDType.getUUID(o1).timestamp();
>        long t2 = LexicalUUIDType.getUUID(o2).timestamp();
>        return t1 < t2 ? -1 : (t1 > t2 ? 1 :
> FBUtilities.compareByteArrays(o1, o2));

:-)

Yes, this makes sense, so it is a two-part sort, not just latter part.

-+ Tatu +-

ps. Not sure if this matters, but I am finally working on Java Uuid
Generator v3, which might help with time-location based UUIDs. Will
announce it on the list when it's ready (in couple of weeks)

Reply via email to