1 Reply Latest reply: May 31, 2012 12:53 AM by 720657 RSS

    Filtering unnecessary events in a time window using CQL

    Martin Jarvis-Oracle
      Hi,

      I can't get my head around how to do something which I thought would be quite simple. I have a stream of events with events arriving at random intervals every 3-5 seconds. Once I receive an event I don't need to respond to another event of that same type for another minute. Once that minute is up I want to wait until a new event of that same type arrives and start the process again. Can you give me some pointers?

      Martin
        • 1. Re: Filtering unnecessary events in a time window using CQL
          720657
          The following should work -

          Let S be the input stream and let schema of S have an attribute "type". Then,
          select T.Ac1 from S
              MATCH_RECOGNIZE ( 
                  PARTITION BY type
                  MEASURES 
                      A.c1 as Ac1 
                  PATTERN(A) 
                  DEFINE 
                      A as (prev(A.c1,1,60*10^9) is null)
              ) as T
          What the above query does is it outputs the input event if there is no previous event of the same type (the PARTITION BY clause creates 1 logical sub-stream per type) that was received within the last 60 seconds (expressed in nanos)