Search code examples
c#streaminsight

Will TumblingWindow fire when there is no event?


StreamInsight TumblingWindow will it fire off if there's no event?

All examples I have seen like the one here, always have an event inside each window: http://sqlblog.com/blogs/stream_insight/archive/2010/12/15/windows-in-streaminsight-hopping-vs-snapshot.aspx

But the question is when there is no event in a particular window, will it fire off?


Solution

  • If no event fires inside the window then StreamInsight has no idea the window has passed. StreamInsight has no internal "time" so without something "ticking" it would never know a window has passed or not

    You could build an observable collection that fires every 1 hour and create 10 minute hopping windows. You will not see 6 results.

    void Main(){
    
    var startTime = DateTime.UtcNow;
    
    //Create an arbitrary number of events.
    var source = Application.DefineEnumerable(() => Enumerable.Range(0, 60).Select(i => PointEvent.CreateInsert(startTime.AddHours(i * 1 ), (double)1)));
    var input = source.ToStreamable(AdvanceTimeSettings.StrictlyIncreasingStartTime);
    
    //Create a tumbling window that is 10 seconds wide
    var query = from i in input.TumblingWindow(TimeSpan.FromSeconds(10))
        select i.Count();
    
    query.Dump();
    

    }

    Snapshot windows are slightly different in that they fire because of events rather than fixed time windows.

    Does that help.