Multiple yield return at The Same Event Time in UDSO

Category: sql server streaminsight

Question

yysr on Thu, 23 May 2013 07:51:26


Hello,

I'm using UDSO for some custom operations and it looks like below

My issue is that when the queue "_active" matches the while condition

multiple times (looping several times) yield return gets called also multiple

times within the same event timestamp.

Then when I took a look at my events result displayed on console it seems 

that the returned events are not in the order they were "yield return"ed.

I'd expected the StartTime to be in an increasing order but they are not and

look like ordered by fields' value.

How can I work around this problem? 

Thank you a lot in advance.

Ex. What I'd expected

  EvtTime StartTime field1 field2

     9:01:00 8:56:45 3 8

     9:01:00 8:56:48 1 2

     9:01:00 8:58:45 5 1

Ex. What I see on console

  EvtTime StartTime field1 field2

     9:01:00 8:56:48 1 2

     9:01:00 8:56:45 3 8

     9:01:00 8:58:45 5 1

[DataMember]

readonly Queue<MyType> _active = new Queue<MyType>();

public override IEnumerable<MyType> ProcessEvent(PointEvent<MyType> inputEvent)

{

     if(inputEvent.EventKind==EventKind.Insert)

    _active.Enqueue(inputEvent.Payload);

while(_active.Count()>0 && (inputEvent.Payload.Timestamp-_active.Peek().TimeStamp>TimeSpan.FromMinutes(60))

{

var res = new MyType()

{

   StartTime = _active.Peek().TimeStamp,

   field1 = 1,

   field2 = 2

}

_active.Dequeue();

yield return res;

}

}


Replies

DevBiker on Fri, 24 May 2013 13:58:49


What does your query look like? Where are your CTIs?

yysr on Thu, 30 May 2013 07:32:34


Hi DevBiker,

My query is pretty simple and looks like below.

var udsoStream = from e in cepStream.Scan(new myUDSO())
                                       select e;
runQuery(udsoStream);

I tried to put a breakpoint to catch CTI events inside my UDSO

 if(inputEvent.EventKind==EventKind.Cti)

          //breakpoint here

However, no cti event was caught.

Regards, yysr

DevBiker on Thu, 30 May 2013 15:47:38


Your UDSO won't get any CTIs. And setting breakpoints in a UDSO is a bad idea.

You should output the CTIs to your sink so that you can see, clearly, where the events are within the CTI spans.

You could also look at this in the event flow debugger to see how the events are being ordered in the stream. Finally, what StreamEventOrder are you specifying for the output?

yysr on Tue, 04 Jun 2013 02:47:52


> Your UDSO won't get any CTIs.

Yeah, I didn't get any CTIs inside my UDSO. Why is so?

You should output the CTIs to your sink so that you can see, clearly, where the events are within the CTI spans.

I tried however I couldn't figure out how to do it.

> Finally, what StreamEventOrder are you specifying for the output?

I guess it's

AdvanceTimeSettings.IncreasingStartTime

Regards, yysr

DevBiker on Tue, 04 Jun 2013 13:51:06


I asked the PG about CTIs inside the UDSO at one point in time; I forget their response but it seemed logical at the time. Sorry.

As for outputting CTIs, look at my samples on my blog; they do output CTIs.

And ... StreamEventOrder is for the output. AdvanceTimeSettings.IncreasingStartTime is for input (CTI Policy). The StreamEventOrder controls how events are sent to the output adapters. You have an option of FullyOrdered and ChainOrdered. See http://msdn.microsoft.com/en-us/library/microsoft.complexeventprocessing.streameventorder.aspx.