You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Utku Can Topçu <ut...@topcu.gen.tr> on 2010/06/07 18:04:08 UTC

Getting keys in a range sorted with respect to last access time

Hey All,

First of all I'll start with some questions on the default behavior of
get_range_slices method defined in the thrift API.

Given a keyrange with start-key "kstart" and end-key "kend", assuming
kstart<kend;
* Is it true that I'll get the range [kstart,kend) (kstart inclusive, kend
exclusive)?
* What's the default order of the rows in the result list? (assuming I am
using an OPP)
* (How) can we reverse the sorting order?
* What would be the behavior in the case kstart>kend? Will I get an empty
result list?

Secondly, I have use case where I need to access the latest updated rows?
How can this be possible? Writing a new partitioner?

Best Regards,
Utku

Re: Getting keys in a range sorted with respect to last access time

Posted by Jonathan Ellis <jb...@gmail.com>.
On Mon, Jun 7, 2010 at 9:04 AM, Utku Can Topçu <ut...@topcu.gen.tr> wrote:
> Hey All,
>
> First of all I'll start with some questions on the default behavior of
> get_range_slices method defined in the thrift API.
>
> Given a keyrange with start-key "kstart" and end-key "kend", assuming
> kstart<kend;
> * Is it true that I'll get the range [kstart,kend) (kstart inclusive, kend
> exclusive)?

[start, end]

> * What's the default order of the rows in the result list? (assuming I am
> using an OPP)

lexically by unicode code point

> * (How) can we reverse the sorting order?

write your own ReversedOPP.  but maybe you mean "how do we scan in
reversed order," in which case the answer is, "extend
ColumnFamilyStore.getRangeRows" (not for the faint of heart, but not
impossible).

> * What would be the behavior in the case kstart>kend? Will I get an empty
> result list?

pretty sure it will error out.  easy to verify experimentally.

> Secondly, I have use case where I need to access the latest updated rows?
> How can this be possible? Writing a new partitioner?

No.  You'd want to maintain a separate row containing the most recent updates.

-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com