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/10/21 15:44:00 UTC
Reading a keyrange when using RP
If I'm not mistaken cassandra has been providing support for keyrange
queries also on RP.
However when I try to define a keyrange such as, start: (key100, end:
key200) I get an error like:
InvalidRequestException(why:start key's md5 sorts after end key's md5. this
is not allowed; you probably should not specify end key at all, under
RandomPartitioner)
How can I utilize cassandra to get a keyrange in RP?
Best Regards,
Utku
Re: Reading a keyrange when using RP
Posted by Tyler Hobbs <ty...@riptano.com>.
It's possible with a second row/column family.
In another Column Family, create a row where all of the column names are
the row keys you want to be able to get a range of. Pick the comparator
type for the column family so that the columns will be sorted in the order
you want.
You then get a slice of that row, take the column names you get back,
and multiget those as rows in the original column family. The multiget
results are unordered, but it's easy to order them in linear time.
- Tyler
On Thu, Oct 21, 2010 at 12:55 PM, Utku Can Topçu <ut...@topcu.gen.tr> wrote:
> The goal is actually getting the rows in the range of "start","end"
>
> The order is not important at all.
>
> But what I can see is, this does not seem to be possible at all using RP.
> Am I wrong?
>
>
> On Thu, Oct 21, 2010 at 6:03 PM, Tyler Hobbs <ty...@riptano.com> wrote:
>
>> You can't get rows back in order with RP.
>>
>> You can start out with a start key and end key of '' (empty) and use the
>> row count argument instead, if
>> your goal is paging the rows. To get the next page, start from the last
>> key you got in the
>> previous page.
>>
>>
>> On Thu, Oct 21, 2010 at 8:44 AM, Utku Can Topçu <ut...@topcu.gen.tr>wrote:
>>
>>> If I'm not mistaken cassandra has been providing support for keyrange
>>> queries also on RP.
>>>
>>> However when I try to define a keyrange such as, start: (key100, end:
>>> key200) I get an error like:
>>> InvalidRequestException(why:start key's md5 sorts after end key's md5.
>>> this is not allowed; you probably should not specify end key at all, under
>>> RandomPartitioner)
>>>
>>> How can I utilize cassandra to get a keyrange in RP?
>>>
>>> Best Regards,
>>> Utku
>>>
>>
>>
>
Re: Reading a keyrange when using RP
Posted by Jonathan Ellis <jb...@gmail.com>.
That gets you keys whose MD5s are between the MD5s of start and end,
which is not the same as the keys between start and end.
On Fri, Oct 22, 2010 at 2:07 AM, Oleg Anastasyev <ol...@gmail.com> wrote:
>>
>> The goal is actually getting the rows in the range of "start","end"The order
> is not important at all.But what I can see is, this does not seem to be possible
> at all using RP. Am I wrong?
>
> Simpler solution is just compare MD5 of both keys and set start to one with
> lesser md5 and end to key with greater MD5. RandomPartitioner orders keys by
> their md5, not by value.
>
>
--
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com
Re: Reading a keyrange when using RP
Posted by Oleg Anastasyev <ol...@gmail.com>.
>
> The goal is actually getting the rows in the range of "start","end"The order
is not important at all.But what I can see is, this does not seem to be possible
at all using RP. Am I wrong?
Simpler solution is just compare MD5 of both keys and set start to one with
lesser md5 and end to key with greater MD5. RandomPartitioner orders keys by
their md5, not by value.
Re: Reading a keyrange when using RP
Posted by Utku Can Topçu <ut...@topcu.gen.tr>.
The goal is actually getting the rows in the range of "start","end"
The order is not important at all.
But what I can see is, this does not seem to be possible at all using RP. Am
I wrong?
On Thu, Oct 21, 2010 at 6:03 PM, Tyler Hobbs <ty...@riptano.com> wrote:
> You can't get rows back in order with RP.
>
> You can start out with a start key and end key of '' (empty) and use the
> row count argument instead, if
> your goal is paging the rows. To get the next page, start from the last
> key you got in the
> previous page.
>
>
> On Thu, Oct 21, 2010 at 8:44 AM, Utku Can Topçu <ut...@topcu.gen.tr> wrote:
>
>> If I'm not mistaken cassandra has been providing support for keyrange
>> queries also on RP.
>>
>> However when I try to define a keyrange such as, start: (key100, end:
>> key200) I get an error like:
>> InvalidRequestException(why:start key's md5 sorts after end key's md5.
>> this is not allowed; you probably should not specify end key at all, under
>> RandomPartitioner)
>>
>> How can I utilize cassandra to get a keyrange in RP?
>>
>> Best Regards,
>> Utku
>>
>
>
Re: Reading a keyrange when using RP
Posted by Tyler Hobbs <ty...@riptano.com>.
You can't get rows back in order with RP.
You can start out with a start key and end key of '' (empty) and use the row
count argument instead, if
your goal is paging the rows. To get the next page, start from the last key
you got in the
previous page.
On Thu, Oct 21, 2010 at 8:44 AM, Utku Can Topçu <ut...@topcu.gen.tr> wrote:
> If I'm not mistaken cassandra has been providing support for keyrange
> queries also on RP.
>
> However when I try to define a keyrange such as, start: (key100, end:
> key200) I get an error like:
> InvalidRequestException(why:start key's md5 sorts after end key's md5.
> this is not allowed; you probably should not specify end key at all, under
> RandomPartitioner)
>
> How can I utilize cassandra to get a keyrange in RP?
>
> Best Regards,
> Utku
>