Forum Stats

  • 3,851,620 Users
  • 2,264,005 Discussions
  • 7,904,792 Comments

Discussions

CEP Pattern Matching for Straight line graph

900697
900697 Member Posts: 50
edited Mar 8, 2012 11:39AM in Complex Event Processing
Hi,

I have a scenario where weight is directly proportional to depth, which produces a linear straight line.

CEP will get data for weight and depth, CQL has to be write to raise an event when there is a change in straight line graph.

How to write CQL query and use match pattern for this.

Thanks,
Sri
Tagged:

Answers

  • 720657
    720657 Member Posts: 45
    edited Mar 8, 2012 10:56AM
    So lets say you have an input Channel with event Type E(weight, depth)

    Idea is to compute the slope - weight/depth and report the first and those subsequent events whose w/d is different from that of the previous event

    Here is the query
    SELECT
              T.weight,
              T.depth
    FROM
              E MATCH_RECOGNIZE (
                    MEASURES
                             A.depth as depth,
                             A.weight as weight
                    PATTERN (A)
                    DEFINE
                             A AS ( (PREV(A.weight) is null) OR (PREV(A.weight)/PREV(A.depth) != A.weight/A.depth) )            
              ) as T
    Edited by: Anand Srinivasan on Mar 8, 2012 7:56 AM
    720657
  • 900697
    900697 Member Posts: 50
This discussion has been closed.