cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Derek Williams <de...@fyrie.net>
Subject Re: composite key
Date Sat, 23 Jun 2012 01:51:16 GMT
On Fri, Jun 22, 2012 at 11:49 AM, Juan Ezquerro <juan@sofistic.net> wrote:

> Hi,
>
> I have a column family like:
>
> CREATE COLUMN FAMILY Clients
>     WITH key_validation_class = 'CompositeType(LongType,LongType)'  --
> master_id,client_id
>     AND comparator = UTF8Type
>     AND column_metadata = [
>     {column_name: client_name, validation_class: UTF8Type,index_type:
> KEYS}
>     ];
>
> The key are like:
>
> 1:12345
> 1:67890
> 6:12345
> 6:67890
> 11:12345
> 11:67890
>
> I would like to get keys who start with 1, i try with for example:
>
> $start = array(1);
> $end = array(1);
>
> $cf->get_range($start,$end);
>
> I try a lot of combo but not work, can help please?
>

Cassandra's default is to store the rows randomly (using a hash of the
key), so there isn't a way of retrieving the keys that match some filter
without iterating through all of them. There are some things you can do,
like use an ordered partitioner to store the rows in order, but that is not
recommended because you wont get even distribution throughout our cluster.

I think your best bet though is just use the master_id for your row key,
and then use composite columns that begin with the client_id.

-- 
Derek Williams

Mime
View raw message