incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aditya Narayan <ady...@gmail.com>
Subject Re: Concatenating ids with extension to keep multiple rows related to an entity in a single CF
Date Fri, 04 Nov 2011 06:23:25 GMT
the data in different rows of an entity  is all of similar type but serves
different features but still has almost similar storage and retrieval needs
thus I wanted to put them in one CF and reduce column families.

>From my knowledge, I believe compositeType existed for columns as
an alternative choice to implement something similar to supercolumns, are
there any cassandra's built in features to design composite keys using two
provided Integer ids.

Is my approach correct and recommended if I need to keep multiple rows
related to an entity in single CF ?

On Fri, Nov 4, 2011 at 10:11 AM, Tyler Hobbs <tyler@datastax.com> wrote:

> On Thu, Nov 3, 2011 at 3:48 PM, Aditya Narayan <adynnn@gmail.com> wrote:
>
>> I am concatenating  two Integer ids through bitwise operations(as
>> described below) to create a single primary key of type long. I wanted to
>> know if this is a good practice. This would help me in keeping multiple
>> rows of an entity in a single column family by appending different
>> extensions to the entityId.
>> Are there better ways ? My Ids are of type Integer(4 bytes).
>>
>>
>>     public static final long makeCompositeKey(int k1, int k2){
>>         return (long)k1 << 32 | k2;
>>     }
>>
>
> You could use an actual CompositeType(IntegerType, IntegerType), but it
> would use a little extra space and not buy you much.
>
> It doesn't sound like this is the case for you, but if you have several
> distinct types of rows, you should consider using separate column families
> for them rather than putting them all into one big CF.
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>
>

Mime
View raw message