Friday 14 February 2020

Cassandra: Get the token value for given partition key

The token function allows to compute the token for a given partition key.

cqlsh> SELECT * FROM cassandratutorial.employee;

 id | age | firstname | lastname
----+-----+-----------+----------
  1 |  30 |   Krishna |   Gurram
  2 |  31 |       Ram |   Gurram
  4 |  45 |    Chitra |    Rajan
  3 |  45 |     Vijay |   Ponnam

(4 rows)
cqlsh> 
cqlsh> SELECT id, TOKEN(id) from cassandratutorial.employee;

 id | system.token(id)
----+----------------------
  1 | -4069959284402364209
  2 | -3248873570005575792
  4 | -2729420104000364805
  3 |  9010454139840013625

(4 rows)



Previous                                                    Next                                                    Home

No comments:

Post a Comment