Cassandra ByteOrderedPartitioner

后端 未结 2 1629
后悔当初
后悔当初 2020-12-04 02:21

I want to execute some range queries on a table that is structured like:

CREATE TABLE table(

num int,
val1 int,
val2 float,
val3 text,
...
PRIMARY KEY(num)
         


        
2条回答
  •  我在风中等你
    2020-12-04 03:19

    Using Byte Order Partitioner is an anti-pattern in Cassandra for sure, but if you still want to go ahead with it, then you can achieve the above functionality of range queries over partition key using the token function.

    SELECT num, val1, val2 FROM tableorderedbynum WHERE someotherkey = 'yourvalue' AND 
    token(num) > token(100) AND token(num) < token(1000);
    

    Please be advised similar queries will fail to provide desired results when using Random Partitioner or Murmur3 Partitioner because token's are not generated in order but are random in nature.

提交回复
热议问题