> create column family Comments > with comparator = 'CompositeType(UTF8Type(reversed=True), UTF8Type)' > and key_validation_class = 'UTF8Type' > and default_validation_class = 'UTF8Type'; Looks ok.
> SELECT FIRST 100 REVERSED 'z'..'0' from Comments where key = 'xyz'; try SELECT FIRST 100 REVERSED * from Comments where key = 'xyz'; Cheers ----------------- Aaron Morton Freelance Developer @aaronmorton http://www.thelastpickle.com On 24/03/2012, at 9:41 AM, Praveen Baratam wrote: > 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.