incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Loy <ketera...@gmail.com>
Subject Re: working with time uuid
Date Mon, 06 Jun 2011 15:53:21 GMT
well, to clarify, it first checks the timestamp bytes, then the rest so it
doesn;t say they're the same if they came from 2 different servers.


On Mon, Jun 6, 2011 at 4:52 PM, Paul Loy <keteracel@gmail.com> wrote:

>     private static int compareTimestampBytes(ByteBuffer o1, ByteBuffer o2)
>     {
>         int o1Pos = o1.position();
>         int o2Pos = o2.position();
>
>         int d = (o1.get(o1Pos+6) & 0xF) - (o2.get(o2Pos+6) & 0xF);
>         if (d != 0) return d;
>
>         d = (o1.get(o1Pos+7) & 0xFF) - (o2.get(o2Pos+7) & 0xFF);
>         if (d != 0) return d;
>
>         d = (o1.get(o1Pos+4) & 0xFF) - (o2.get(o2Pos+4) & 0xFF);
>         if (d != 0) return d;
>
>         d = (o1.get(o1Pos+5) & 0xFF) - (o2.get(o2Pos+5) & 0xFF);
>         if (d != 0) return d;
>
>         d = (o1.get(o1Pos) & 0xFF) - (o2.get(o2Pos) & 0xFF);
>         if (d != 0) return d;
>
>         d = (o1.get(o1Pos+1) & 0xFF) - (o2.get(o2Pos+1) & 0xFF);
>         if (d != 0) return d;
>
>         d = (o1.get(o1Pos+2) & 0xFF) - (o2.get(o2Pos+2) & 0xFF);
>         if (d != 0) return d;
>
>         return (o1.get(o1Pos+3) & 0xFF) - (o2.get(o2Pos+3) & 0xFF);
>     }
>
>
> Looks like it's only comparing the timestamp bytes.
>
>
> On Mon, Jun 6, 2011 at 4:06 PM, Patrick Julien <pjulien@gmail.com> wrote:
>
>> How does this work exactly?  If you're using generation 1 time uuids
>> for your keys to get ordering, doesn't this mean the keys need to be
>> generated all on the same host when you either query or insert?  Or
>> does cassandra only inspect the bits that represent the time stamp of
>> the UUID when performing a lookup?
>>
>
>
>
> --
> ---------------------------------------------
> Paul Loy
> paul@keteracel.com
> http://uk.linkedin.com/in/paulloy
>



-- 
---------------------------------------------
Paul Loy
paul@keteracel.com
http://uk.linkedin.com/in/paulloy

Mime
View raw message