我正在尝试使用 cli 中的 Cassandra CounterColumnFamily 进行一些基本查询。我基本上有一个列族“page_view_counts”,其中行键作为 url。每行有 3 个与之相关的计数(展示次数、转化次数和收入)。我已经索引了其中一个计数,因为我想检索转换 > 10 等的行。
这是描述 page_view_counts 的输出:
ColumnFamily: page_view_counts
Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type
Default column value validator: org.apache.cassandra.db.marshal.CounterColumnType
Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
GC grace seconds: 864000
Compaction min/max thresholds: 4/32
Read repair chance: 0.1
DC Local Read repair chance: 0.0
Replicate on write: true
Caching: KEYS_ONLY
Bloom Filter FP chance: default
Column Metadata:
Column Name: conversion
Validation Class: org.apache.cassandra.db.marshal.CounterColumnType
Index Name: page_view_counts_conversion_idx
Index Type: KEYS
Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
Compression Options:
sstable_compression: org.apache.cassandra.io.compress.SnappyCompressor
我的列族中的一些示例数据:
RowKey: row27
=> (counter=conversion, value=27000)
=> (counter=impression, value=54000)
=> (counter=revenue, value=81000)
-------------------
RowKey: row29
=> (counter=conversion, value=29000)
=> (counter=impression, value=58000)
=> (counter=revenue, value=87000)
-------------------
RowKey: row81
=> (counter=conversion, value=81000)
=> (counter=impression, value=162000)
=> (counter=revenue, value=243000)
但是当我执行以下查询时出现这些错误:
[default@hector] get page_view_counts where conversion>23;
invalid operation for commutative columnfamily page_view_counts
[default@hector] get page_view_counts where conversion=long('1000');
invalid operation for commutative columnfamily page_view_counts
[default@hector] get page_view_counts where conversion=1000;
invalid operation for commutative columnfamily page_view_counts
[default@hector] get page_view_counts where KEY='row81';
java.lang.NumberFormatException: An hex string representing bytes must have an even length
[default@hector] get page_view_counts where KEY=bytes('row81');
java.lang.RuntimeException: java.lang.RuntimeException: org.apache.cassandra.db.marshal.MarshalException: cannot parse 'row81' as hex bytes
[default@hector] get page_view_counts where KEY=utf8('row81');
invalid operation for commutative columnfamily page_view_counts
有人可以帮我吗?
谢谢。