2016-08-23 7 views
0

Ich habe folgende siddhi query verwendet, um die Anzahl der Ereignisse pro Minute zu erhalten; ts als timestamp (string) und ftp_requests als count (int).WSO2CEP: Abrufen des vorherigen Ereigniswerts aus dem Stream in Siddhi-Abfrage

from FTPInStream[command == 'USER'] 
select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T',' '), 5, 'hour',"yyyy-MM-dd HH:mm:ss"),'yyyy-MM-dd HH:mm') as milliseconds , uid, id_orig_h, id_orig_p, id_resp_h, id_resp_p 
insert into intermediateStream; 

from intermediateStream#window.externalTimeBatch(milliseconds ,1 min, milliseconds, 1 min) 
select time:dateFormat(milliseconds, 'yyyy-MM-dd HH:mm') as ts , cast(count(milliseconds), 'int') as ftp_requests 
group by milliseconds 
insert into FTPOutStream; 

Wenn ich will vorherigen Wert von ftp_requests in jedem neuen Wert hinzufügen, um die kumulative Anzahl der Anfragen mit jeder neuen Anfragen zu bekommen, welche Änderung erforderlich wäre? Gibt es irgendeine Funktion in Siddhi, um den vorherigen Ereigniswert vom bereits veröffentlichten Stream zu erhalten?

Antwort

0

Sie sollten nicht group by milliseconds verwenden, und count() sollte keine params erfordern, sowie es nicht in int eingegegnet werden muss. Versuchen Sie die folgende Abfrage.

from FTPInStream[command == 'USER'] 
select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T',' '), 5, 'hour',"yyyy-MM-dd HH:mm:ss"),'yyyy-MM-dd HH:mm') as milliseconds , uid, id_orig_h, id_orig_p, id_resp_h, id_resp_p 
insert into intermediateStream; 

from intermediateStream#window.externalTimeBatch(milliseconds ,1 min, milliseconds, 1 min) 
select time:dateFormat(milliseconds, 'yyyy-MM-dd HH:mm:ss') as ts , count() as ftp_requests 
insert into FTPOutStream; 
Verwandte Themen