cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Laban <>
Subject Re: Composite keys and range queries
Date Wed, 14 Mar 2012 00:05:21 GMT
Forwarding to the Cassandra mailing list as well, in case this is more of
an issue on how I'm using Cassandra.

Am I correct to assume that I can use range queries on composite row keys,
even when using a RandomPartitioner, if I make sure that the first part of
the composite key is fixed?

Any help would be appreciated,

On Tue, Mar 13, 2012 at 12:15 PM, John Laban <> wrote:

> Hi,
> I have a column family that uses a composite key:
> (ID, priority) -> ...
> Where the ID is a UUID and the priority is an integer.
> I'm trying to perform a range query now:  I want all the rows where the ID
> matches some fixed UUID, but within a range of priorities.  This is
> supported even if I'm using a RandomPartitioner, right?  (Because the first
> key in the composite key is the partition key, and the second part of the
> composite key is automatically ordered?)
> So I perform a range slices query:
> val rangeQuery = HFactory.createRangeSlicesQuery(keyspace, new CompositeSerializer, StringSerializer.get,
> rangeQuery.setColumnFamily(RouteColumnFamilyName).
>             setKeys( new Composite(id, priorityStart), new Composite(id, priorityEnd)
>             setRange( null, null, false, Int.MaxValue )
> But I get this error:
> me.prettyprint.hector.api.exceptions.HInvalidRequestException: 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)
> Shouldn't they have the same md5, since they have the same partition key?
> Am I using the wrong query here, or does Hector not support composte range
> queries, or am I making some mistake in how I think Cassandra's composite
> keys work?
> Thanks,
> John

View raw message