You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Ravikumar Govindarajan <ra...@gmail.com> on 2013/04/17 13:25:47 UTC

Key-Token mapping in cassandra

We would like to map multiple keys to a single token in cassandra. I
believe this should be possible now with CASSANDRA-1034

Ex:

Key1 --> 123/IMAGE
Key2 --> 123/DOCUMENTS
Key3 --> 123/MULTIMEDIA

I would like all keys with "123" as prefix to be mapped to a single token.

Is this possible? What should be the Partitioner that I should most likely
extend and write my own to achieve the desired result?

--
Ravi

Re: Key-Token mapping in cassandra

Posted by aaron morton <aa...@thelastpickle.com>.
> There are many more such CFs all with prefixes of "grpId". By hashing grpId to cassandra's token, I thought we can co-locate all the group's data into one set of replicated nodes.
> 
> Is there a way to achieve this?
No. 

Rows with the same row key are stored on the same nodes. Rows with different row keys are generally stored on different nodes. 

This can be handy for something like user data. But it can also be dangerous if you decide to manually locate large amounts of data, as you risk overloading particular nodes which have to deal with hot spots in the data model. 

Cheers

-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton
http://www.thelastpickle.com

On 20/04/2013, at 4:57 AM, Ravikumar Govindarajan <ra...@gmail.com> wrote:

> I think I have simplified my example a little too much.
> 
> Lets assume that there are groups and users.
> 
> Ideally a grpId becomes the key and it holds some meta-data.
> 
> Lets say GroupMetaCF
> 
> grpId --> key, entityId --> col-name, blobdata --> col-value
> 
> Now we have a UserTimeSeriesCF
> 
> grpId/userId --> key, UUID --> col-name, entityId --> col-value
> 
> [Each user will view a subset of the grp data, based on roles etc...]
> 
> There are many more such CFs all with prefixes of "grpId". By hashing grpId to cassandra's token, I thought we can co-locate all the group's data into one set of replicated nodes.
> 
> Is there a way to achieve this?
> 
> --
> Ravi
> 
> 
> On Thu, Apr 18, 2013 at 1:26 PM, aaron morton <aa...@thelastpickle.com> wrote:
> All rows with the same key go on the same nodes. So if you use the same row key in different CF's they will be on the same nodes. i.e. have CF's called Image, Documents, Meta and store rows in all of them with the 123 key. 
> 
> Cheers
> 
> -----------------
> Aaron Morton
> Freelance Cassandra Consultant
> New Zealand
> 
> @aaronmorton
> http://www.thelastpickle.com
> 
> On 18/04/2013, at 1:32 PM, Ravikumar Govindarajan <ra...@gmail.com> wrote:
> 
>> Thanks Aaron.
>>  We are looking at co-locating all keys for a given user in one Cassandra node.
>> Are there any other ways to achieve this
>> 
>> --
>> Ravi
>> 
>> On Thursday, April 18, 2013, aaron morton wrote:
>>> CASSANDRA-1034
>> That ticket is about removing an assumption which was not correct. 
>> 
>>> I would like all keys with "123" as prefix to be mapped to a single token.
>> Why? 
>> it's not possible nor desirable IMHO. Tokens are used to identify a single row internally. 
>>  
>> Cheers
>> 
>> -----------------
>> Aaron Morton
>> Freelance Cassandra Consultant
>> New Zealand
>> 
>> @aaronmorton
>> http://www.thelastpickle.com
>> 
>> On 17/04/2013, at 11:25 PM, Ravikumar Govindarajan <ra...@gmail.com> wrote:
>> 
>>> We would like to map multiple keys to a single token in cassandra. I believe this should be possible now with CASSANDRA-1034
>>> 
>>> Ex:
>>> 
>>> Key1 --> 123/IMAGE
>>> Key2 --> 123/DOCUMENTS
>>> Key3 --> 123/MULTIMEDIA
>>> 
>>> I would like all keys with "123" as prefix to be mapped to a single token.
>>> 
>>> Is this possible? What should be the Partitioner that I should most likely extend and write my own to achieve the desired result?
>>> 
>>> --
>>> Ravi
>> 
> 
> 


Re: Key-Token mapping in cassandra

Posted by Ravikumar Govindarajan <ra...@gmail.com>.
I think I have simplified my example a little too much.

Lets assume that there are groups and users.

Ideally a grpId becomes the key and it holds some meta-data.

Lets say GroupMetaCF

grpId --> key, entityId --> col-name, blobdata --> col-value

Now we have a UserTimeSeriesCF

grpId/userId --> key, UUID --> col-name, entityId --> col-value

[Each user will view a subset of the grp data, based on roles etc...]

There are many more such CFs all with prefixes of "grpId". By hashing grpId
to cassandra's token, I thought we can co-locate all the group's data into
one set of replicated nodes.

Is there a way to achieve this?

--
Ravi


On Thu, Apr 18, 2013 at 1:26 PM, aaron morton <aa...@thelastpickle.com>wrote:

> All rows with the same key go on the same nodes. So if you use the same
> row key in different CF's they will be on the same nodes. i.e. have CF's
> called Image, Documents, Meta and store rows in all of them with the 123
> key.
>
> Cheers
>
> -----------------
> Aaron Morton
> Freelance Cassandra Consultant
> New Zealand
>
> @aaronmorton
> http://www.thelastpickle.com
>
> On 18/04/2013, at 1:32 PM, Ravikumar Govindarajan <
> ravikumar.govindarajan@gmail.com> wrote:
>
> Thanks Aaron.
>  We are looking at co-locating all keys for a given user in one Cassandra
> node.
> Are there any other ways to achieve this
>
> --
> Ravi
>
> On Thursday, April 18, 2013, aaron morton wrote:
>
>> CASSANDRA-1034
>>
>> That ticket is about removing an assumption which was not correct.
>>
>> I would like all keys with "123" as prefix to be mapped to a single token.
>>
>> Why?
>> it's not possible nor desirable IMHO. Tokens are used to identify a
>> single row internally.
>>
>> Cheers
>>
>>    -----------------
>> Aaron Morton
>> Freelance Cassandra Consultant
>> New Zealand
>>
>> @aaronmorton
>> http://www.thelastpickle.com
>>
>> On 17/04/2013, at 11:25 PM, Ravikumar Govindarajan <
>> ravikumar.govindarajan@gmail.com> wrote:
>>
>> We would like to map multiple keys to a single token in cassandra. I
>> believe this should be possible now with CASSANDRA-1034
>>
>> Ex:
>>
>> Key1 --> 123/IMAGE
>> Key2 --> 123/DOCUMENTS
>> Key3 --> 123/MULTIMEDIA
>>
>> I would like all keys with "123" as prefix to be mapped to a single token.
>>
>> Is this possible? What should be the Partitioner that I should most
>> likely extend and write my own to achieve the desired result?
>>
>> --
>> Ravi
>>
>>
>>
>

Re: Key-Token mapping in cassandra

Posted by "Hiller, Dean" <De...@nrel.gov>.
It should be Key4 --> 123

And you store it in the Image CF or the Documents CF or the MultiMedia CF….then it ends up all on the same machine as the CF breaks the row apart.

Dean

From: Alicia Leong <lc...@gmail.com>>
Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Date: Thursday, April 18, 2013 8:24 PM
To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Subject: Re: Key-Token mapping in cassandra

Hi Ravi

Key1 --> 123/IMAGE
Key2 --> 123/DOCUMENTS
Key3 --> 123/MULTIMEDIA


Which one is your ROW KEY ??   It is Key1,Key2,Key3?




On Thu, Apr 18, 2013 at 3:56 PM, aaron morton <aa...@thelastpickle.com>> wrote:
All rows with the same key go on the same nodes. So if you use the same row key in different CF's they will be on the same nodes. i.e. have CF's called Image, Documents, Meta and store rows in all of them with the 123 key.

Cheers

-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton
http://www.thelastpickle.com

On 18/04/2013, at 1:32 PM, Ravikumar Govindarajan <ra...@gmail.com>> wrote:

Thanks Aaron.
 We are looking at co-locating all keys for a given user in one Cassandra node.
Are there any other ways to achieve this

--
Ravi

On Thursday, April 18, 2013, aaron morton wrote:
CASSANDRA-1034
That ticket is about removing an assumption which was not correct.

I would like all keys with "123" as prefix to be mapped to a single token.
Why?
it's not possible nor desirable IMHO. Tokens are used to identify a single row internally.

Cheers

-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton
http://www.thelastpickle.com<http://www.thelastpickle.com/>

On 17/04/2013, at 11:25 PM, Ravikumar Govindarajan <ra...@gmail.com> wrote:

We would like to map multiple keys to a single token in cassandra. I believe this should be possible now with CASSANDRA-1034

Ex:

Key1 --> 123/IMAGE
Key2 --> 123/DOCUMENTS
Key3 --> 123/MULTIMEDIA

I would like all keys with "123" as prefix to be mapped to a single token.

Is this possible? What should be the Partitioner that I should most likely extend and write my own to achieve the desired result?

--
Ravi




Re: Key-Token mapping in cassandra

Posted by Alicia Leong <lc...@gmail.com>.
Hi Ravi

Key1 --> 123/IMAGE
Key2 --> 123/DOCUMENTS
Key3 --> 123/MULTIMEDIA


Which one is your ROW KEY ??   It is Key1,Key2,Key3?




On Thu, Apr 18, 2013 at 3:56 PM, aaron morton <aa...@thelastpickle.com>wrote:

> All rows with the same key go on the same nodes. So if you use the same
> row key in different CF's they will be on the same nodes. i.e. have CF's
> called Image, Documents, Meta and store rows in all of them with the 123
> key.
>
> Cheers
>
> -----------------
> Aaron Morton
> Freelance Cassandra Consultant
> New Zealand
>
> @aaronmorton
> http://www.thelastpickle.com
>
> On 18/04/2013, at 1:32 PM, Ravikumar Govindarajan <
> ravikumar.govindarajan@gmail.com> wrote:
>
> Thanks Aaron.
>  We are looking at co-locating all keys for a given user in one Cassandra
> node.
> Are there any other ways to achieve this
>
> --
> Ravi
>
> On Thursday, April 18, 2013, aaron morton wrote:
>
>> CASSANDRA-1034
>>
>> That ticket is about removing an assumption which was not correct.
>>
>> I would like all keys with "123" as prefix to be mapped to a single token.
>>
>> Why?
>> it's not possible nor desirable IMHO. Tokens are used to identify a
>> single row internally.
>>
>> Cheers
>>
>>    -----------------
>> Aaron Morton
>> Freelance Cassandra Consultant
>> New Zealand
>>
>> @aaronmorton
>> http://www.thelastpickle.com
>>
>> On 17/04/2013, at 11:25 PM, Ravikumar Govindarajan <
>> ravikumar.govindarajan@gmail.com> wrote:
>>
>> We would like to map multiple keys to a single token in cassandra. I
>> believe this should be possible now with CASSANDRA-1034
>>
>> Ex:
>>
>> Key1 --> 123/IMAGE
>> Key2 --> 123/DOCUMENTS
>> Key3 --> 123/MULTIMEDIA
>>
>> I would like all keys with "123" as prefix to be mapped to a single token.
>>
>> Is this possible? What should be the Partitioner that I should most
>> likely extend and write my own to achieve the desired result?
>>
>> --
>> Ravi
>>
>>
>>
>

Re: Key-Token mapping in cassandra

Posted by aaron morton <aa...@thelastpickle.com>.
All rows with the same key go on the same nodes. So if you use the same row key in different CF's they will be on the same nodes. i.e. have CF's called Image, Documents, Meta and store rows in all of them with the 123 key. 

Cheers

-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton
http://www.thelastpickle.com

On 18/04/2013, at 1:32 PM, Ravikumar Govindarajan <ra...@gmail.com> wrote:

> Thanks Aaron.
>  We are looking at co-locating all keys for a given user in one Cassandra node.
> Are there any other ways to achieve this
> 
> --
> Ravi
> 
> On Thursday, April 18, 2013, aaron morton wrote:
>> CASSANDRA-1034
> That ticket is about removing an assumption which was not correct. 
> 
>> I would like all keys with "123" as prefix to be mapped to a single token.
> Why? 
> it's not possible nor desirable IMHO. Tokens are used to identify a single row internally. 
>  
> Cheers
> 
> -----------------
> Aaron Morton
> Freelance Cassandra Consultant
> New Zealand
> 
> @aaronmorton
> http://www.thelastpickle.com
> 
> On 17/04/2013, at 11:25 PM, Ravikumar Govindarajan <ra...@gmail.com> wrote:
> 
>> We would like to map multiple keys to a single token in cassandra. I believe this should be possible now with CASSANDRA-1034
>> 
>> Ex:
>> 
>> Key1 --> 123/IMAGE
>> Key2 --> 123/DOCUMENTS
>> Key3 --> 123/MULTIMEDIA
>> 
>> I would like all keys with "123" as prefix to be mapped to a single token.
>> 
>> Is this possible? What should be the Partitioner that I should most likely extend and write my own to achieve the desired result?
>> 
>> --
>> Ravi
> 


Re: Key-Token mapping in cassandra

Posted by Ravikumar Govindarajan <ra...@gmail.com>.
Thanks Aaron.
 We are looking at co-locating all keys for a given user in one Cassandra
node.
Are there any other ways to achieve this

--
Ravi

On Thursday, April 18, 2013, aaron morton wrote:

> CASSANDRA-1034
>
> That ticket is about removing an assumption which was not correct.
>
> I would like all keys with "123" as prefix to be mapped to a single token.
>
> Why?
> it's not possible nor desirable IMHO. Tokens are used to identify a single
> row internally.
>
> Cheers
>
> -----------------
> Aaron Morton
> Freelance Cassandra Consultant
> New Zealand
>
> @aaronmorton
> http://www.thelastpickle.com
>
> On 17/04/2013, at 11:25 PM, Ravikumar Govindarajan <
> ravikumar.govindarajan@gmail.com <javascript:_e({}, 'cvml',
> 'ravikumar.govindarajan@gmail.com');>> wrote:
>
> We would like to map multiple keys to a single token in cassandra. I
> believe this should be possible now with CASSANDRA-1034
>
> Ex:
>
> Key1 --> 123/IMAGE
> Key2 --> 123/DOCUMENTS
> Key3 --> 123/MULTIMEDIA
>
> I would like all keys with "123" as prefix to be mapped to a single token.
>
> Is this possible? What should be the Partitioner that I should most likely
> extend and write my own to achieve the desired result?
>
> --
> Ravi
>
>
>

Re: Key-Token mapping in cassandra

Posted by aaron morton <aa...@thelastpickle.com>.
> CASSANDRA-1034
That ticket is about removing an assumption which was not correct. 

> I would like all keys with "123" as prefix to be mapped to a single token.
Why? 
it's not possible nor desirable IMHO. Tokens are used to identify a single row internally. 
 
Cheers

-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton
http://www.thelastpickle.com

On 17/04/2013, at 11:25 PM, Ravikumar Govindarajan <ra...@gmail.com> wrote:

> We would like to map multiple keys to a single token in cassandra. I believe this should be possible now with CASSANDRA-1034
> 
> Ex:
> 
> Key1 --> 123/IMAGE
> Key2 --> 123/DOCUMENTS
> Key3 --> 123/MULTIMEDIA
> 
> I would like all keys with "123" as prefix to be mapped to a single token.
> 
> Is this possible? What should be the Partitioner that I should most likely extend and write my own to achieve the desired result?
> 
> --
> Ravi