Fixed Duration Non-Event Detection

19-26 Oracle Complex Event Processing CQL Language Reference subset_name::= const_string::= on page 7-12 non_mt_corr_list::= correlation_name::= on page 19-11 Consider the query q55 in Example 19–27 and the data stream S11 in Example 19–28 . Stream S11 has schema c1 integer, c2 integer. This example defines subsets S1 through S6. This query outputs a match if the c2 attribute values in the input stream form the shape of the English letter W. Now suppose we want to know the sum of the values of c2 for those tuples which form the incrementing arms of this W shape. The correlation variable X represents tuples that are part of the first incrementing arm and Z represent the tuples that are part of the second incrementing arm. So we need some way to group the tuples that match both. Such a requirement can be captured by defining a SUBSET clause as the example shows. Subset S4 is defined as X,Z. It refers to the tuples in the input stream that match either X or Z. This subset is used in the MEASURES clause statement sumS4.c2 as sumIncrArm. This computes the sum of the value of c2 attribute in the tuples that match either X or Z. A reference to S4.c2 in a DEFINE clause like S4.c2 = 10 will refer to the value of c2 in the latest among the last tuple that matched X and the last tuple that matched Z. Subset S6 is defined as Y. It refers to all the tuples that match correlation variable Y. The query returns the stream in Example 19–29 . Example 19–27 MATCH_RECOGNIZE with SUBSET Clause Query query id=q55[CDATA[ select T.firstW, T.lastZ, T.sumDecrArm, T.sumIncrArm, T.overallAvg from S11 MATCH_RECOGNIZE MEASURES S2.c1 as firstW, lastS1.c1 as lastZ, sumS3.c2 as sumDecrArm, sumS4.c2 as sumIncrArm, avgS5.c2 as overallAvg PATTERNA W+ X+ Y+ Z+ SUBSET S1 = Z S2 = A S3 = A,W,Y S4 = X,Z S5 = A,W,X,Y,Z S6 = Y DEFINE W as W.c2 prevW.c2, X as X.c2 prevX.c2, Y as S6.c2 prevY.c2, Z as Z.c2 prevZ.c2 as T ]]query Pattern Recognition With MATCH_RECOGNIZE 19-27 Example 19–28 MATCH_RECOGNIZE with SUBSET Clause Stream Input Timestamp Tuple 1000 1,8 2000 2,8 3000 3,8 4000 4,6 5000 5,3 6000 6,7 7000 7,6 8000 8,2 9000 9,6 10000 10,2 11000 11,9 12000 12,9 13000 13,8 14000 14,5 15000 15,0 16000 16,9 17000 17,2 18000 18,0 19000 19,2 20000 20,3 21000 21,8 22000 22,5 23000 23,9 24000 24,9 25000 25,4 26000 26,7 27000 27,2 28000 28,8 29000 29,0 30000 30,4 31000 31,4 32000 32,7 33000 33,8 34000 34,6 35000 35,4 36000 36,5 37000 37,1 38000 38,7 39000 39,5 40000 40,8 41000 41,6 42000 42,6 43000 43,0 44000 44,6 45000 45,8 46000 46,4 47000 47,3 48000 48,8 49000 49,2 50000 50,5 51000 51,3 52000 52,3 53000 53,9 54000 54,8 55000 55,5 56000 56,5 57000 57,9 58000 58,7 59000 59,3 60000 60,3 Example 19–29 MATCH_RECOGNIZE with SUBSET Clause Stream Output Timestamp Tuple Kind Tuple