将列从int更改为varint后的Cassandra Select问题

时间:2016-12-28 16:37:07

标签: cassandra cql

Cassandra中的varint有什么特别之处吗?我有一个带有varint列的表,并且以下select语句不起作用:

select * from hourly_average where application_id = 3 and partner_id = 1 and location_id = 1 and device_id = 10003;

application_id,partner_id和location_id是varints。如果我将它们转换为常规int,那么select语句可以正常工作。当它们是varints时,它返回0结果,即使有很多结果与这些值匹配。

更新:添加了表格定义:

CREATE TABLE myschema.hourly_average (
    application_id varint,
    partner_id varint,
    location_id varint,
    device_id int,
    day date,
    hour int,
    average float,
    count int,
    max float,
    min float,
    PRIMARY KEY ((application_id, partner_id, location_id, device_id), day, hour)
) WITH CLUSTERING ORDER BY (day DESC, hour DESC)
    AND bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

select *

的一些输出
 application_id | partner_id | location_id | device_id | day        | hour | average    | count | max  | min
----------------+------------+-------------+-----------+------------+------+------------+-------+------+------
              3 |          1 |           1 |     20004 | 2016-12-01 |    2 |          0 |     1 |    0 |    0
              3 |          1 |           1 |     20004 | 2016-12-01 |    1 |          0 |     2 |    0 |    0
              3 |          1 |           1 |     20004 | 2016-12-01 |    0 |          0 |     2 |    0 |    0
              3 |          1 |           1 |     20004 | 2016-11-30 |   23 |          0 |     2 |    0 |    0
              3 |          1 |           1 |     10003 | 2016-12-01 |    2 | 1290.80017 |    75 | 1553 |  820
              3 |          1 |           1 |     10003 | 2016-12-01 |    1 |  888.19165 |   120 |  957 |  830
              3 |          1 |           1 |     10003 | 2016-12-01 |    0 |  991.09167 |   120 | 1062 |  896

版本是dsc-cassandra 3.0.9。

注:

它似乎与最初为int的列有关,我改变了表并使其成为varint。如果我创建一个只有一个int类型的列的全新表,添加一些数据,然后将其更改为varint类型,则会出现同样的问题。将列类型从int更改为varint是否存在某种错误?

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题,尽管我不认为我们将列类型从int更改为varint-从一开始就是varint。

对我唯一有用的是双重转换黑客:

(...) where key = blobAsVarint(intAsBlob(1))