Cassandra的田间值的自动估计

发布于 2025-01-24 13:48:17 字数 207 浏览 4 评论 0原文

有一个Cassandra桌子,如下所示。

  Student(eName text, eId int PRIMARY KEY, m1 int, m2 int, average float) 

如何在行其他字段的插入值时自动估计? 也就是说,我们只需要插入ENAME,EID,M1和M2;平均必须自动估计并输入元组。

谢谢。

There is a Cassandra table as follows.

  Student(eName text, eId int PRIMARY KEY, m1 int, m2 int, average float) 

How can the average value be autocalculated on inserting values for other fields of the row?
That is, we need to insert only eName, eId, m1 and m2; average has to be autocalculated and entered in the tuple.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哭泣的笑容 2025-01-31 13:48:17

卡桑德拉(Cassandra例如avg()计算查询返回的所有值的平均值,也就是说,聚合发生在读取时间(而不是写入时间)。

您还可以编写自己的用户定义的聚合(UDA)。

可以实现自己的 当数据写入表格时执行Java代码的执行,但长期以来被认为是实验性的,我不建议使用它。

一般建议是在将数据写入表格之前执行您的应用程序中的汇总。干杯!

Cassandra has built-in CQL aggregate functions such as AVG() which computes the average of all values returned by a query, that is, the aggregation takes place at read time (as opposed to write time).

You can also write your own user-defined aggregates (UDAs).

It is possible to implement your own CQL TRIGGER which executes Java code when data is written to a table but it has been considered as experimental for a long time and I don't recommend using it.

The general recommendation is to perform the aggregation within your application prior to writing the data to the table. Cheers!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文