当查询在卡桑德拉CQL文本主键,字符串比较工作的什么人预期相反的方向,即字符串在卡桑德拉排序CQL
cqlsh:test> select * from sl; name | data --------------------------+------ 000000020000000000000003 | null 000000010000000000000005 | null 000000010000000000000003 | null 000000010000000000000002 | null 000000010000000000000001 | null cqlsh:test> select name from sl where token(name) < token('000000010000000000000005'); name -------------------------- 000000020000000000000003 (1 rows) cqlsh:test> select name from sl where token(name) > token('000000010000000000000005'); name -------------------------- 000000010000000000000003 000000010000000000000002 000000010000000000000001 (3 rows)
在constrast,这是我从字符串比较得到在Python(我认为在大多数其他语言):
>>>'000000020000000000000003' < '000000010000000000000005'
False
如果我查询,而不令牌功能,我得到以下错误:
cqlsh:test> select name from sl where name < '000000010000000000000005'; Bad Request: Only EQ and IN relation are supported on the partition key (unless you use the token() function)
表描述是:
CREATE TABLE sl (
name text,
data blob,
PRIMARY KEY (name)
) WITH
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
index_interval=128 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
default_time_to_live=0 AND
speculative_retry='99.0PERCENTILE' AND
memtable_flush_period_in_ms=0 AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'LZ4Compressor'};
有没有在我已经错过了或其他地方,为什么选择这样一个奇怪的字符串比较顺序的文档的解释,或者做字符串比较操作就不是我所期望它(即返回一些不相关的顺序,即将它们写入数据库时的顺序)。我使用Murmur3Partitioner分区程序以防万一。
谢谢你,我很困惑,行似乎是在DESC顺序排序,但它看起来像一个纯粹的巧合。项目进行的方式我不需要太多的分区,所以我可能会使用有序的分区程序,或者完全使用应用程序级别的排序和比较。 – alexk 2014-09-30 15:14:43
@alexk只是警告,字节顺序分区程序已被弃用,应该*不能*被使用。 http://www.datastax.com/documentation/cassandra/2.1/cassandra/architecture/architecturePartitionerBOP_c.html – Aaron 2014-09-30 15:22:05