我正在尝试使用来自cli的Cassandra CounterColumnFamily进行一些基本查询。我基本上有一个列系列'page_view_counts',其中Row Key为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
有人可以帮帮我吗?
感谢。
答案 0 :(得分:1)
试试这个:
assume page_view_counts keys as UTF8Type;
get page_view_counts['row81'];