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