You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by ChingShen <ch...@gmail.com> on 2010/08/12 10:50:55 UTC

Re: Can I retrieve specific key range from a table in RandomPartitioner?

I have a key range that between 0000000000 and 0000001000, and my code as
below:

SlicePredicate predicate = new SlicePredicate();
predicate.setColumn_names(columns);
ColumnParent parent = new ColumnParent(columnFamily);
KeyRange k = new KeyRange(1000);
k.setStart_key(key[0]);
k.setEnd_key(key[1000]);
List<KeySlice> results = client.get_range_slices(keyspace, parent,
predicate, k, ConsistencyLevel.ONE);

On Thu, Aug 12, 2010 at 4:44 PM, ChingShen <ch...@gmail.com> wrote:

> Hi all,
>
>    Can I retrieve specific key range from a table in RandomPartitioner?
> Because I always got below exception:
> Exception in thread "main" 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)
>
> Thanks.
>
> Shen
>

Re: Can I retrieve specific key range from a table in RandomPartitioner?

Posted by Aaron Morton <aa...@thelastpickle.com>.
Try setting the end key to an empty string, and then set the number of rows to something sane and make multiple calls if needed. Or you may be able to make your own secondary index another CF, so you do two reads: one on the secondary index then one of the rows you want.

There has been some discussion about range slices with RP recently that may be helpful see http://www.mail-archive.com/user@cassandra.apache.org/msg05017.html


Aaron

On 12 Aug, 2010,at 08:50 PM, ChingShen <ch...@gmail.com> wrote:

I have a key range that between 0000000000 and 0000001000, and my code as below:

SlicePredicate predicate = new SlicePredicate();
predicate.setColumn_names(columns);
ColumnParent parent = new ColumnParent(columnFamily);
KeyRange k = new KeyRange(1000);
k.setStart_key(key[0]);
k.setEnd_key(key[1000]);
List<KeySlice> results = client.get_range_slices(keyspace, parent, predicate, k, ConsistencyLevel.ONE);        

On Thu, Aug 12, 2010 at 4:44 PM, ChingShen <ch...@gmail.com> wrote:
Hi all,

   Can I retrieve specific key range from a table in RandomPartitioner? Because I always got below exception:
Exception in thread "main" 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)

Thanks.

Shen