You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by A J <s5...@gmail.com> on 2012/08/13 21:33:55 UTC

Custom Partitioner Type

Is it possible to use a custom Partitioner type (other than RP or BOP) ?
Say if my rowkeys are all Integers and I want all even keys to go to
node1 and odd keys to node2, is it feasible ? How would I go about ?

Thanks.

Re: Custom Partitioner Type

Posted by aaron morton <aa...@thelastpickle.com>.
Yes, you need to implement the org.apache.cassandra.dht.IPartitioner interface, there are a couple of abstract implementations you could base it on. 

> I want all even keys to go to
> node1 and odd keys to node2, is it feasible ?

I'm not endorsing the idea of doing this, but as a hack to see if the effects you could use the BOP and format the keys as (python):

str(key % 2) + "{0:0>#10}".format(key)

So all keys are 11 digit strings, even keys start with 0 and odd with 1. 

Hope that helps. 

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 14/08/2012, at 7:33 AM, A J <s5...@gmail.com> wrote:

> Is it possible to use a custom Partitioner type (other than RP or BOP) ?
> Say if my rowkeys are all Integers and I want all even keys to go to
> node1 and odd keys to node2, is it feasible ? How would I go about ?
> 
> Thanks.