Indexing cassandra:带有索引表达式的查询不';行不通
我试图通过以下查询从Cassandra处获取数据:Indexing cassandra:带有索引表达式的查询不';行不通,indexing,cassandra,phpcassa,Indexing,Cassandra,Phpcassa,我试图通过以下查询从Cassandra处获取数据: $cf=new ColumnFamily($data->cp,'ips'); $index[]=CassandraUtil::create_index_expression('c',1,'EQ'); $index[]=CassandraUtil::create_index_expression('begin_ip',1599147740,'GTE'); $index[]=CassandraUtil::create_index_expres
$cf=new ColumnFamily($data->cp,'ips');
$index[]=CassandraUtil::create_index_expression('c',1,'EQ');
$index[]=CassandraUtil::create_index_expression('begin_ip',1599147740,'GTE');
$index[]=CassandraUtil::create_index_expression('end_ip',1599147740,'LTE');
$index_clause = CassandraUtil::create_index_clause($index);
$rows=$cf->get_indexed_slices($index_clause);
foreach($rows AS $key=>$row)
{
$result[]=$row;
}
var_dump($result);
但是结果是null。
我肯定cfips
中有一行绝对回答了这个问题
所有列的验证类都是IntegerType
在cassandra cli中,相等查询:
get ips where c = int('1') and
begin_ip <= int('1599147740') and
end_ip >= int('1599147740');
获取IP,其中c=int('1')和
begin_ip=int('1599147740');
还获取null
我做错了什么?首先,您是否在“c”列上创建了索引
其次,对于表达式运算符,您需要使用“cassandra_IndexOperator::EQ”和类似命令,而不是字符串。Yes“c”列有索引。我试过了。现在查询的时间比我的发送时间(60000毫秒)/接收时间(60000毫秒)长期间,这一切都会导致在本地主机上执行get_indexed_切片时出现异常
错误:9160:exception'cassandra_TimedOutException
,并且在查询结束时出现消息“尝试执行get_indexed_切片失败6次”的未捕获异常MaxRetriesException'。最后一个错误是cassandra_TimedOutException:
为什么会发生这种情况?CF有近300万行,每行有4列,值“c”总是1,这意味着所有300万行都匹配?是的,我特别添加了此列和此值,以便能够与EQ运算符以及其他运算符一起使用这是一个非常低效的查询。您应该考虑将“ip”编号存储为列名,并获取一个列片段,而不是使用辅助索引。