Reputation: 57
I am trying out some basic queries with Cassandra CounterColumnFamily from the cli. I basically have a column family 'page_view_counts' with Row Key as url. Each row has 3 counts (impressions, conversions and revenue) associated with it. I have indexed one of the counts as I want to retrieve rows with conversion > 10 etc.
This is output for describe 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
some sample data in my column family:
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)
But I am getting these errors when I do the following queries :
[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
Can someone please help me with this?
Thanks.
Upvotes: 1
Views: 951
Reputation: 8985
Try this:
assume page_view_counts keys as UTF8Type;
get page_view_counts['row81'];
Upvotes: 1