incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Praveen Baratam <praveen.bara...@gmail.com>
Subject CQL Reversed and Comparator reversed=true
Date Fri, 23 Mar 2012 20:41:06 GMT
Hello,

I am a bit confused about how to store and retrieve columns in Reversed
order.

Currently I store comments for every blog post in a wide row per post.

I want to store and retrieve comments for each blog post in
reversed/descending order for efficiency as we display comments in
descending order by time. Each comment gets a time based sortable id which
is stored as part of the first component of the composite type.

Below is the create statement for the column family that stores comments
for posts.

create column family Comments
    with comparator = 'CompositeType(UTF8Type(reversed=True), UTF8Type)'
    and key_validation_class = 'UTF8Type'
    and default_validation_class = 'UTF8Type';

and the CQL I use to retrieve is as follows

SELECT FIRST 100 REVERSED 'z'..'0' from Comments where key = 'xyz';

Am I doing the right thing?

Are the comments stored in descending time order in CF and with this CQL
Query am I retrieving the columns in their natural sort order with out any
additional sorting overhead?

Thank you.

Mime
View raw message