cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "" <>
Subject I: Re: Are row-keys sorted by the compareWith?
Date Mon, 21 Feb 2011 22:09:38 GMT

As Jonathan mentions the compareWith on a column family def. is defines the order for the
columns *within* a row... In order to control the ordering of rows you'll need to use the
OrderPreservingPartitioner (

Thanks for your answer and for your time, I will take a look at this.

As for getColumnsFromRows; it should be returning you a map of lists.  The map is insertion-order-preserving
and populated based on the provided list of row keys (so if you iterate over the entries in
the map they should be in the same order as the list of row keys).  

mmm ... well it didn't happen like this. In my code I had a CF named comments and also a CF
called usercomments. UserComments use an uuid as row-key to keep, TimeUUID sorted, the "pointers"
to the comments of the user. When I get the sorted list of keys from the UserComments and
I use this list as row-keys-list in the GetColumnsFromRows I don't get back the data sorted
as I expect them to be.It looks like if Cassandra/Pelops does not care on how I provide the
row-keys-list. I am sure about that cause I did something different: I iterate over my row-keys-list
and made many GetColumnFromRow instead of one GetColumnsFromRows and when I iterate data are
correctly sorted. But this can not be a solution ...
I am using Cassandra 0.6.9
I profit of your knownledge of Pelops to ask you something: I am evaluating the migration
to Cassandra 0.7 ... as far as you know, in terms of written code, is it an heavy job?
Best Regards

----Messaggio originale----


                On Saturday, 19 February 2011 at 8:16 AM, wrote:
                    Hi all,
I created a CF in which i need to get, sorted by time, the Rows inside. Each 
Row represents a comment.

<ColumnFamily name="Comments" compareWith="TimeUUIDType" / >

I've created a few rows using as Row Key a generated TimeUUID but when I call 
the Pelops method "GetColumnsFromRows" I don't get the data back as I expect: 
rows are not sorted by TimeUUID.
I though it was probably cause of the random-part of the TimeUUID so I create 
a new CF ...

<ColumnFamily name="Comments2" compareWith="LongType" / >

This time I created a few rows using the java System.CurrentTimeMillis() that 
retrieve a long. I call again the "GetColumnsFromRows" and again the same 
results: data are not sorted!
I've read many times that Rows are sorted as specified in the compareWith but 
I can't see it. 
To solve this problem for the moment I've used a SuperColumnFamily with an 
UNIQUE ROW ... but I think this is just a workaround and not the solution.

<ColumnFamily name="Comments" type="Super" compareWith="TimeUUIDType"  
CompareSubcolumnsWith="BytesType"/ >

Now when I call the "GetSuperColumnsFromRow" I get all the SuperColumns as I 
expected: sorted by TimeUUID. Why it does not happen the same with the Rows? 
I'm confused.

TIA for any help.

Best Regards




View raw message