I have a Cassandra table as below:
create table experience.userstats (stream varchar, user varchar, computer varchar, experience varchar, amount int, primary key (experience, stream, user, computer);
I am using Apache storm bolts to create these records in Cassandra from a queue spout.
I want to generate aggregate statistics and display the counter for different experiences for a given stream as a pie chart. For example, 30% satisfied, 40% mixed and 30% unsatisfied experience.
Since I cannot update counters online, I am using a Clock spout (timer) to read this data and generate counters into a new table. But Cassandra does not support group by clauses and hence I have to read thrice to get the counter for each experience as below.
select count(*) from experience.userstats where experience='satisfied' and stream='xyz';
select count(*) from experience.userstats where experience='unsatisfied' and stream='xyz';
select count(*) from experience.userstats where experience='mixed' and stream='xyz';
The problem with this approach is that I have to execute three queries on database to get the counters for the 3 types of experience and experience could be modified in the mean-time making these counters inconsistent.
Is there a way I can execute above three select statements in a single batch? Or could you please suggest an alternative design approach?