You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Juan Ezquerro <ju...@sofistic.net> on 2012/06/22 19:49:33 UTC

composite key

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?

I expect:

1:12345
1:67890

-- 
Juan Ezquerro LLanes <Sofistic Team>

Telf: 618349107/964051479

Re: composite key

Posted by "dong.yajun" <do...@gmail.com>.
Hi

I think you can use an ordered partitioner to store the rows in order,
then, you can refer to the implementation of openTSDB which solves the
timeseries data using composite key in Hbase.

schema design in openTSDB: http://opentsdb.net/schema.html


On Sat, Jun 23, 2012 at 9:51 AM, Derek Williams <de...@fyrie.net> wrote:

> On Fri, Jun 22, 2012 at 11:49 AM, Juan Ezquerro <ju...@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
>
>


-- 
*Ric Dong *
Newegg Ecommerce, MIS department

Re: composite key

Posted by Juan Ezquerro <ju...@sofistic.net>.
Hi,

Thanks for your answer.


> 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.
>


In this case I believe that the supercolumn approach can be valid. This CF
only store a little amount of data for any user and no often changes, i
think a supercolumn and some file caching of results can be a nice solution
with no penalty in performance.

-- 
Juan Ezquerro LLanes <Sofistic Team>

Telf: 618349107/964051479

Re: composite key

Posted by Derek Williams <de...@fyrie.net>.
On Fri, Jun 22, 2012 at 11:49 AM, Juan Ezquerro <ju...@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