简体   繁体   English

wso2 cep-SiddhiQL-对同一事件表中的不同行求和

[英]wso2 cep - SiddhiQL - sum different rows from the same event table

I have one event table called eventCount and has the following values: 我有一个名为eventCount的事件表,并具有以下值:

ID  |   eventCount
1            3
2            1
3            5
4            1

I have a stream of data coming in where I count the values of a certain type for a time period (1 second) and depending on the type and time period I will count() and write the value of the count() in the correspondent row. 我有一个数据流进入,其中我会在一段时间(1秒)内对某种类型的值进行计数,并且根据类型和时间段,我将count()并将count()的值写入对应的行。

I need to make a sum of the values within the event table. 我需要对事件表中的值求和。

I tried to create another event table and join both. 我试图创建另一个事件表并同时加入两者。 Although I am getting the error of you cannot join from 2 static sources. 虽然我得到的错误是您无法从2个静态来源加入。

What is the correct way of doing this from SIddiQL in WSO2 CEP 在WSO2 CEP中从SIddiQL执行此操作的正确方法是什么

In your scenario, Sum of the values in the event table is equivalent to the total number of events, doesn't it? 在您的方案中,事件表中值的总和等于事件总数,不是吗? So why you need to keep it an event table, can't you just it then and there (like below)? 那么,为什么需要将其保留为事件表,难道不能就此将其保留(如下所示)?

@Import('dataIn:1.0.0')
define stream dataIn (id int);

@Export('totalCountStream:1.0.0')
define stream totalCountStream (eventCount long);

@Export('perIdCountStream:1.0.0')
define stream perIdCountStream (id int, eventCount long);

partition with (id of dataIn)
begin
    from dataIn#window.time(5 sec)
    select id, count() as eventCount
    insert into perIdCountStream;
end;

from dataIn#window.time(5 sec)
select count() as eventCount
insert into totalCountStream;

ps: if you really need the event tables, you can always persist totalCountStream and perIdCountStream in two separate tables. ps:如果您确实需要事件表,则可以始终将totalCountStream和perIdCountStream保留在两个单独的表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM