Cassandra Apache查询 [英] Cassandra Apache query

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

问题描述

我在cassandra中的表格有问题。以下是我的工作:

I have a problems with a table in cassandra. Below is what I did:

使用REPLICATION = {'class':'SimpleStrategy','replication_factor':1}创建键空间tfm;

我在一台机器上工作。

创建表tfm.foehis(hocpny文本,hocol文本, honumr文本,holinh文本,hodt文本,hotour文本,hoclic文本,hooe文本,hotpac文本,hodtac文本,hohrac文本,hodesf文本,hocdan文本,hocdrs文本,hocdsl文本,hoobs文本,hotdsc文本,honrac文本,holinr文本,housca文本,hodtea文本,hohrea文本,housea文本,hodtcl文本,hohrcl文本,houscl文本,hodtrc文本,hohrrc文本,housrc文本,hodtra文本,hohrra文本,housra文本,hodtcm文本,hohrcm文本,houscm文本,hodtua text,hohrua text,houser text,PRIMARY KEY((hooe,hodtac,hohrac),hoclic));

直到这一点一切正常。但是,当我尝试执行一些选择查询时,会收到警告和错误:

Until this point everything is OK. But when I try to do some select queries, I get warnings and errors:

cqlsh>从tfm.foehis中选择count(*);

count

-------

56980

(1行)

警告:
使用没有分区键的聚合查询

读取100条实时行和1055个逻辑删除单元用于查询SELECT * FROM tfm.foehis LIMIT 100(请参见tombstone_warn_threshold)

读取100条实时行和1066个逻辑删除单元以进行查询SELECT * FROM tfm.foehis WHERE令牌(hooe,hodtac,hohrac)> =令牌(1045161613,20180502,2304)限制100(请参见tombstone_warn_threshold)

cqlsh>从tfm.foehis中选择count(*),其中hoclic = 1011;

InvalidRequest:来自服务器的错误:code = 2200 [无效查询] message =对于 hoclic无效的INTEGER常数(1011)。类型为text c>

cqlsh>从tfm.foehis中选择count(*),其中hotpac = ANOE;

SyntaxException:行1:49输入' ;'(...来自tfm.foehis,其中hotpac = [ANOE];)

我认为问题出在表的定义中,但是我不知道问题出在哪里。

I supposed that the problems is in the definition of table, but I don't know where the problems is.

推荐答案

实际上,您的问题出在查询中。由于所有列都是文本,因此您需要在值周围使用简单的引号。

Actually your issue is in the queries. Since all your columns are text you need to use simple quotes around values.

此外,根据您的表定义,分区键由hooe,hodtac,hohrac列组成这意味着您所有的查询都必须包含具有精确值(=)的此列。 hoclic将成为集群列,在这一列上,您将可以使用其他运算符和排序。

Also, according to your table definition, the partition key is formed by hooe,hodtac,hohrac columns which means that all your queries must include this columns with exact values (=). hoclic will be the clustering column and on this one you will be able to use other operators and ordering.

此外,请记住,没有分区键的运行查询不是建议在Cassandra中使用(如您的选择),因为这将触发完整的群集扫描,并且您可以运行各种问题(例如,垃圾回收问题)。

Also, have in mind that running queries without the partition key is not recommended in Cassandra (like your select) since this will trigger a full cluster scan and you can run in all sorts of problems (for instance, garbage collection issues).

I会推荐一些基本的读物: https://www.datastax.com/dev/blog/the-most-important-thing-to-know-in-cassandra-data-modeling-the-primary-key https://docs.datastax.com/en/cql/3.3/ index.html

I would recommend some basic reading: https://www.datastax.com/dev/blog/the-most-important-thing-to-know-in-cassandra-data-modeling-the-primary-key and https://docs.datastax.com/en/cql/3.3/index.html

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

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