0

我正在研究流处理器 4.3.0。我遇到了一种情况,我使用 siddhiapp 将一些数据馈送到 rdbms 表中。使用 siddiapp,我在 RDBMS 表中输入数据,如下所示

在此处输入图像描述

现在,我正在使用另一个 SiddhiApp 来检索数据,但我想尝试以如下方式获取数据

在此处输入图像描述

由于公共列被缩小以进入一行,并且现在对具有计数的列求和以获得所有计数的最终总和。

有人可以指导我如何在这里进行。

提前致谢

这是获得总和的应用程序

    @App:name("IncomingStream3")
    @App:description("Description of the plan")

    -- Please refer to https://docs.wso2.com/display/SP400/Quick+Start+Guide on getting started with SP editor. 

    --@store(type = 'rdbms', datasource = 'APIM_ANALYTICS_DB')
    --@purge(enable='false', interval='60 min', @retentionPeriod(sec='1 day', min='72 hours', hours='90 days', days='1 year', months='2 years', years='3 years'))

    define stream  TempStatsStream (AGG_TIMESTAMP long, AGG_EVENT_TIMESTAMP long, apiName string, apiVersion string, apiResourcePath string,apiCreator string,username string, applicationConsumerKey string, AGG_LAST_EVENT_TIMESTAMP long, applicationName string, dateTime string, AGG_COUNT int);

    define aggregation StatsToCal

    from TempStatsStream
    select apiName, apiVersion, apiResourcePath, apiCreator, username, applicationName, 
    applicationConsumerKey, SUM (AGG_COUNT) as totalRequestCount, dateTime

    group by apiName, apiVersion, apiResourcePath, username, applicationConsumerKey
    aggregate by dateTime every days;

我在这里所做的唯一更改不是从数据库表中获取值,而是将其视为流(因为聚合只能针对流进行,我想)。

4

1 回答 1

0

似乎您必须按 API、Name1、Name2 和 ID 分组?您可以使用group by类似于 SQL group by

from TriggerStream join APITable
select APIName, Name1, Name2, ID, sum(Count) as totalCount
group by API, Name1, Name2, ID
insert into OutputStream;
于 2019-09-26T17:30:02.237 回答