How does Apache Cassandra do aggregate operations?

2019-04-21 00:34发布

问题:

I'm fairly new to Apache Cassandra and nosql in general.

In SQL I can do aggregate operations like:

SELECT 
  country, sum(age) / count(*) AS averageAge 
FROM people 
GROUP BY country;

This is nice because it is calculated within the DB, rather than having to move every row in the 'people' table into the client layer to do the calculation.

Is this possible in Apache Cassandra? How?

回答1:

Cassandra is primarily a mechanism that supports fast writes and look-ups. There is no support for calculations like aggregates in SQL since it is not designed for that. I would suggest reading of popular Cassandra use-cases to get a better insight :) I have bookmarked some articles on my delicious page. Here is the link:

http://delicious.com/vibhutesagar/cassandra



回答2:

Using SliceRange could be thought of as Cassandra's version of LIMIT and ORDER BY.

GROUP BY, COUNT and SUM is not supported out of the box.

Taking a look at the API page from the wiki is a good start.



回答3:

Current version of Cassandra do not support SUM(). Only count(*) is supported.