You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Paul Prescod <pa...@prescod.net> on 2010/04/07 15:45:59 UTC

Sorting and ordering in Cassandra

I'm working on a blog post that combines all of the information and
ideas I can find relative to managing sorted lists in Cassandra.

http://jottit.com/s8c4a/#

Not only do I greatly appreciate comments, I actually don't think I
can publish it without some feedback because there are some embedded
questions.

Thanks in advance for any help.

 Paul

Re: Sorting and ordering in Cassandra

Posted by Paul Prescod <pr...@gmail.com>.
On Thu, Apr 8, 2010 at 12:34 PM, Peter Chang <pe...@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

Re: Sorting and ordering in Cassandra

Posted by Peter Chang <pe...@gmail.com>.
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.

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



On Thu, Apr 8, 2010 at 8:15 AM, Jonathan Ellis <jb...@gmail.com> wrote:

> Re "Why couldn't you walk though random-layout hash-keyed data by
> token the same way? The hashes still have an order."
>
> You can in 0.6.
>
> On Wed, Apr 7, 2010 at 8:45 AM, Paul Prescod <pa...@prescod.net> wrote:
> > I'm working on a blog post that combines all of the information and
> > ideas I can find relative to managing sorted lists in Cassandra.
> >
> > http://jottit.com/s8c4a/#
> >
> > Not only do I greatly appreciate comments, I actually don't think I
> > can publish it without some feedback because there are some embedded
> > questions.
> >
> > Thanks in advance for any help.
> >
> >  Paul
> >
>

Re: Sorting and ordering in Cassandra

Posted by Jonathan Ellis <jb...@gmail.com>.
Re "Why couldn't you walk though random-layout hash-keyed data by
token the same way? The hashes still have an order."

You can in 0.6.

On Wed, Apr 7, 2010 at 8:45 AM, Paul Prescod <pa...@prescod.net> wrote:
> I'm working on a blog post that combines all of the information and
> ideas I can find relative to managing sorted lists in Cassandra.
>
> http://jottit.com/s8c4a/#
>
> Not only do I greatly appreciate comments, I actually don't think I
> can publish it without some feedback because there are some embedded
> questions.
>
> Thanks in advance for any help.
>
>  Paul
>