views:

244

answers:

1

How can i access recent 10 values from cassandra. i need to get the recent values from a particular super column. I am getting the result, but which is not sorted properly. i need to sort the result with descending order(latest first based on the column name/timestamp)

+1  A: 

Without knowing the precise application it's quite hard to give a definite answer for your needs, but in general and if I understand you correctly then as a SuperColumn has no timestamp data, I believe you would need to key each of your SuperColumns with perhaps a timestamp or other numerical key, and then define a CompareWith="LongType" (or similar, check documentation) in the storage config XML.

This would result in each of your SuperColumns within the scope being sorted by ascending key. To retrieve the most recent, then, you would need to set the reversed attribute on your SliceRange to true (how exactly this is done will depend on the language/library you're using). See http://wiki.apache.org/cassandra/API#SliceRange

Hopefully this will be a point in the right direction :).

James

jstephenson