How does Apache Cassandra do aggregate operations?

2019-04-21 00:16发布

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?

3条回答
可以哭但决不认输i
2楼-- · 2019-04-21 01:07

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

查看更多
萌系小妹纸
3楼-- · 2019-04-21 01:17

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

查看更多
成全新的幸福
4楼-- · 2019-04-21 01:21

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.

查看更多
登录 后发表回答