Domanda

If I have a point stream with point data from several 'units' identified with a UnitId and Start Date:

var input = CepStream<EventPayload>.Create("input", typeof(SQLPayloadInputAdapterFactory), inputConfig, EventShape.Point);

and I convert it to an interval stream :

var signal = input .AlterEventDuration(e => TimeSpan.MaxValue) .ClipEventDuration(input, (e1, e2) => (e1.UnitID == e2.UnitID));

I can get the duration of the events in the signal stream when read by the output adapter as this can see the event object and read its start and end values.

What I need to do is query the 'signal' stream to find the longest event in a 1 min tumbling window

var groupWindowQuery = from e in signal
                       group e by e.UnitID into unitGroups
                       from window in unitGroups.TumblingWindow(
                       TimeSpan.FromSeconds(60),
                       HoppingWindowOutputPolicy.ClipToWindowEnd)
                                   select new
                                   {
                                       id = unitGroups.Key,
                                       count = window.Count(),
                                   };

... Gives me groups of units with counts etc but i cannot get the duration of the event to pass through to other queries as i can only see payload values in the groupWindowQuery.

How can i query the event properties to find the longest event in the tumbling window?

Or is it possible to set values in the payload so i could give my point events an end date when creating the signal stream from points?

(doesn't matter that the duration would be 1 min for events that span the window)

È stato utile?

Soluzione

What you need to do is to get the duration of the event and then use that in the query. Unfortunately, you can't do that directly. But that doesn't mean that it can't be done. :-) Here's one option: http://www.devbiker.net/post/How-long-did-that-edge-event-take.aspx. The other option is to use an Edge UDSO rather than a subject. Here are the docs for that: http://technet.microsoft.com/en-us/library/hh290514.aspx. While the example shows a PointStreamOperator, the EdgeStreamOperator works the same way. If you go this route, you'd use the end edge to calculate the duration and then yield return the result. Of the two methods, the EdgeStreamOperator is probably better; using a subject creates a new stream timeline that you really don't need (even if it is completely sync'd to the source) and the UDSO will be a little more efficient.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top