cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Prescod <pres...@gmail.com>
Subject Re: Sorting and ordering in Cassandra
Date Thu, 08 Apr 2010 22:03:24 GMT
On Thu, Apr 8, 2010 at 12:34 PM, Peter Chang <peter78@gmail.com> wrote:
> Eagerly reading this post. One line here doesn't make sense to me.
> "Out of the box, Cassandra does not support TimeUUIDs for sorting an
> OrderPreservingPartitioner."
> Does this mean you can't use Time UUIDs when using OPP? Or that the keys
> will not have their order preserved? If it's the latter, perhaps a one
> sentence explanation on why would help as I assumed it would've.

I think that if you look at the UUID standard, it just doesn't "sort"
properly. It's low order byte first, which is analogous to listing a
time second:minute:hour . When you sort naively, you sort by the
second rather than the hour.

Here's the code from TimeUUID.java

        long t1 = LexicalUUIDType.getUUID(o1).timestamp();
        long t2 = LexicalUUIDType.getUUID(o2).timestamp();
        return t1 < t2 ? -1 : (t1 > t2 ? 1 :
FBUtilities.compareByteArrays(o1, o2));

I'll add a bit to the document to clarify.

> Otherwise, great reading so far. Very helpful and wish I found this earlier.

Glad to help!

 Paul Prescod

Mime
View raw message