You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Yuhan Zhang <yz...@onescreen.com> on 2013/02/01 01:36:03 UTC

rangeQuery to traverse keys backward?

Hi all,

I'm tryinng to use get_range to traverse the rows by page by providing a
:start_key and an :finish_key.

This works fine when I traverse forward with :start_key=>last_key,
:finish_key=>""
However, when I tried to traversed backward with :start_key="",
:finish_key=>first_key, this always gave me the first few rows in the
column family.
(my goal is to get  the rows adjacent to my "first_key")

looks like it always takes priority of :start_key over the :finish_key.

as for column range,  there is an option to reverse the order. but there is
an option for  traversing rows.
so I'm wondering whether cassandra is capable of doing this task with the
current api

I tried both twitter cassandra client and hector client, but couldn't find
a way to perform it.
have someone been able to do this?


Thank you

Yuhan

-- 
The information contained in this e-mail is for the exclusive use of the 
intended recipient(s) and may be confidential, proprietary, and/or legally 
privileged. Inadvertent disclosure of this message does not constitute a 
waiver of any privilege.  If you receive this message in error, please do 
not directly or indirectly print, copy, retransmit, disseminate, or 
otherwise use the information. In addition, please delete this e-mail and 
all copies and notify the sender.

Re: rangeQuery to traverse keys backward?

Posted by aaron morton <aa...@thelastpickle.com>.
There is no facility to do a get_range in reverse. 

Rows are ordered by their token, and using the Random or Murmur3 partitioner this means they are randomly ordered. So there is not much need to go backwards, or get 10 rows from either side of a particular row. 

Can you change your data model to not require precise range scans ? 

Cheers

-----------------
Aaron Morton
Freelance Cassandra Developer
New Zealand

@aaronmorton
http://www.thelastpickle.com

On 1/02/2013, at 1:36 PM, Yuhan Zhang <yz...@onescreen.com> wrote:

> Hi all,
> 
> I'm tryinng to use get_range to traverse the rows by page by providing a :start_key and an :finish_key.
> 
> This works fine when I traverse forward with :start_key=>last_key, :finish_key=>""
> However, when I tried to traversed backward with :start_key="", :finish_key=>first_key, this always gave me the first few rows in the column family.
> (my goal is to get  the rows adjacent to my "first_key")
> 
> looks like it always takes priority of :start_key over the :finish_key.
> 
> as for column range,  there is an option to reverse the order. but there is an option for  traversing rows.
> so I'm wondering whether cassandra is capable of doing this task with the current api
> 
> I tried both twitter cassandra client and hector client, but couldn't find a way to perform it.
> have someone been able to do this?
> 
> 
> Thank you
> 
> Yuhan 
> The information contained in this e-mail is for the exclusive use of the intended recipient(s) and may be confidential, proprietary, and/or legally privileged. Inadvertent disclosure of this message does not constitute a waiver of any privilege.  If you receive this message in error, please do not directly or indirectly print, copy, retransmit, disseminate, or otherwise use the information. In addition, please delete this e-mail and all copies and notify the sender.