Re: Composite partition key token

2017-02-09 Thread Branislav Janosik -T (bjanosik - AAP3 INC at Cisco)
Works great, thank you!

On 2/9/17, 6:26 AM, "Michael Burman"  wrote:

Hi,

How about taking it from the BoundStatement directly?

ByteBuffer routingKey = 
b.getRoutingKey(ProtocolVersion.NEWEST_SUPPORTED, codecRegistry);
Token token = metadata.newToken(routingKey);

In this case the b is the "BoundStatement". Replace codecRegistry & 
ProtocolVersion with what you have. codecRegistry for example from the 
codecRegistry = session.getCluster().getConfiguration().getCodecRegistry();

   - Micke


On 02/08/2017 08:58 PM, Branislav Janosik -T (bjanosik - AAP3 INC at 
Cisco) wrote:
>
> Hi,
>
> I would like to ask how to calculate token for composite partition key 
> using java api?
>
> For partition key made of one column I use 
> cluster.getMetadata().newToken(newBuffer);
>
> But what if my key looks like this PRIMARY KEY 
> ((parentResourceId,timeRT), childName)?
>
> I read that “:” is a separator but it doesn’t seem to be the case.
>
> How can I create ByteBuffer with multiple values so that the token 
> would be actually correct?
>
> Thank you,
>
> Branislav
>





Re: Composite partition key token

2017-02-09 Thread Edward Capriolo
On Thu, Feb 9, 2017 at 9:26 AM, Michael Burman  wrote:

> Hi,
>
> How about taking it from the BoundStatement directly?
>
> ByteBuffer routingKey = b.getRoutingKey(ProtocolVersion.NEWEST_SUPPORTED,
> codecRegistry);
> Token token = metadata.newToken(routingKey);
>
> In this case the b is the "BoundStatement". Replace codecRegistry &
> ProtocolVersion with what you have. codecRegistry for example from the
> codecRegistry = session.getCluster().getConfig
> uration().getCodecRegistry();
>
>   - Micke
>
>
> On 02/08/2017 08:58 PM, Branislav Janosik -T (bjanosik - AAP3 INC at
> Cisco) wrote:
>
>>
>> Hi,
>>
>> I would like to ask how to calculate token for composite partition key
>> using java api?
>>
>> For partition key made of one column I use cluster.getMetadata().newToken
>> (newBuffer);
>>
>> But what if my key looks like this PRIMARY KEY
>> ((parentResourceId,timeRT), childName)?
>>
>> I read that “:” is a separator but it doesn’t seem to be the case.
>>
>> How can I create ByteBuffer with multiple values so that the token would
>> be actually correct?
>>
>> Thank you,
>>
>> Branislav
>>
>>
>
This could help:
https://github.com/edwardcapriolo/simple-cassandra-tools/blob/master/src/main/java/io/teknek/cassandra/simple/CompositeTool.java


Re: Composite partition key token

2017-02-09 Thread Michael Burman

Hi,

How about taking it from the BoundStatement directly?

ByteBuffer routingKey = 
b.getRoutingKey(ProtocolVersion.NEWEST_SUPPORTED, codecRegistry);

Token token = metadata.newToken(routingKey);

In this case the b is the "BoundStatement". Replace codecRegistry & 
ProtocolVersion with what you have. codecRegistry for example from the 
codecRegistry = session.getCluster().getConfiguration().getCodecRegistry();


  - Micke


On 02/08/2017 08:58 PM, Branislav Janosik -T (bjanosik - AAP3 INC at 
Cisco) wrote:


Hi,

I would like to ask how to calculate token for composite partition key 
using java api?


For partition key made of one column I use 
cluster.getMetadata().newToken(newBuffer);


But what if my key looks like this PRIMARY KEY 
((parentResourceId,timeRT), childName)?


I read that “:” is a separator but it doesn’t seem to be the case.

How can I create ByteBuffer with multiple values so that the token 
would be actually correct?


Thank you,

Branislav