Cassandra ByteOrderedPartitioner [英] Cassandra ByteOrderedPartitioner

查看:241
本文介绍了Cassandra ByteOrderedPartitioner的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对结构如下的表执行一些范围查询:

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

范围查询应如下所示:

  SELECT num,val1,val2 FROM table WHERE num> 100 AND num< 1000; 

我读过帖子:。在文章中,有三个建模模式。他们应该能够帮助你想出一个合适的数据模型。基本上,您可以使用群集键对数据进行排序,然后使用范围查询...只是不通过您当前的分区键来读取。

  CREATE TABLE tableorderedbynum(
num int,
val1 int,
val2 float,
val3 text,
someotherkey text,
...
PRIMARY KEY((someotherkey),num)
);

检查数据模型,看看是否可以找到另一个键帮助分区数据。然后,如果你创建一个查询表(像我上面的)使用另一个键作为你的分区键,num作为你的聚类键;那么此范围查询将工作:

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


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)
)

A range query should look like:

SELECT num, val1, val2 FROM table WHERE num>100 AND num<1000;

I read ths post: Performing range queries for cassandra table and now I have problems with using the ByteOrderedPartitoner.

I use the OPSCenter Web Interface and try to create a new cluster. I change the Partitioner and the following error appears:

Error provisioning cluster: A token_map argument of the form {ip: token} is required when not using RandomPartitioner or Murmur3Partitioner

I can not find a token_map argument. What am I doing wrong? What else do I have to do to enable the query?

I hope somebody can help me. Thank you!

解决方案

What am I doing wrong?

You are using the Byte Ordered Partitioner. Its use has been identified as a Cassandra anti-pattern...for a while now. Matt Dennis has a slideshare presentation on Cassandra Anti-Patterns, and it contains a slide concerning the BOP:

So while the above slide is meant to be humorous, seriously, do not use the Byte Ordered Partitioner. It is still included with Cassanra, so that those who used it back in 2011 have an upgrade path. No new clusters should be built with the BOP. The (default) Murmur3 partitioner is what you should use.

As for how to solve your problem with the Murmur3 partitioner, the question/answer you linked above refers to Patrick McFadin's article on Getting Started With Time Series Data Modeling. In that article, there are three modeling patterns demonstrated. They should be able to help you come up with an appropriate data model. Basically, you can order your data with a clustering key and then read it with a range query...just not by your current partitioning key.

CREATE TABLE tableorderedbynum(
 num int,
 val1 int,
 val2 float,
 val3 text,
 someotherkey text,
...
PRIMARY KEY((someotherkey),num)
);

Examine your data model, and see if you can find another key to help partition your data. Then, if you create a query table (like I have above) using the other key as your partitioning key, and num as your clustering key; then this range query will work:

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

这篇关于Cassandra ByteOrderedPartitioner的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆