CepStream.TumblingWindow<TPayload> Method (CepStream<TPayload>, TimeSpan, DateTime, WindowInputPolicy, HoppingWindowOutputPolicy)
Transforms a stream to a window stream where each member is a CepWindow. A tumbling window is a special kind of hopping window where window size and hop size are the same. You can also provide an alignment time as a reference for the starting point of the window.
Namespace: Microsoft.ComplexEventProcessing.Linq
Assembly: Microsoft.ComplexEventProcessing (in Microsoft.ComplexEventProcessing.dll)
Syntax
public static CepWindowStream<CepWindow<TPayload>> TumblingWindow<TPayload>(
this CepStream<TPayload> source,
TimeSpan windowSize,
DateTime alignment,
WindowInputPolicy inputPolicy,
HoppingWindowOutputPolicy outputPolicy
)
Type Parameters
- TPayload
The type of the input event payload.
Parameters
- source
Type: Microsoft.ComplexEventProcessing.Linq.CepStream<TPayload>
The CepStream to apply the TumblingWindow operation against.
- windowSize
Type: System.TimeSpan
The length and hop size of the window.
- alignment
Type: System.DateTime
The reference time to align window start times.
- inputPolicy
Type: Microsoft.ComplexEventProcessing.Linq.WindowInputPolicy
Indicates how events are altered before being input into the window operation.
- outputPolicy
Type: Microsoft.ComplexEventProcessing.Linq.HoppingWindowOutputPolicy
Indicates how output events of the window operation are altered
Return Value
Type: Microsoft.ComplexEventProcessing.Linq.CepWindowStream<CepWindow<TPayload>>
A window stream to which aggregates, ranking or user-defined operations can be applied.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type CepStream<TPayload>. When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=sql.105) or https://msdn.microsoft.com/en-us/library/bb383977(v=sql.105).
Remarks
For more information, see Using Event Windows and Hopping Windows.
Examples
var tumblingAgg = from w in inputStream.TumblingWindow(TimeSpan.FromHours(1),
HoppingWindowOutputPolicy.ClipToWindowEnd)
select new { sum = w.Sum(e => e.i) };
The hopping (or tumbling) window alignment is an optional parameter. In the following example, each window starts and ends at 9_00 A.M. UTC.
var snapshotAgg = from w in inputStream.TumblingWindow(
TimeSpan.FromHours(24),
new DateTime(TimeSpan.FromHours(9).Ticks, DateTimeKind.Utc),
HoppingWindowOutputPolicy.ClipToWindowEnd)
select new { sum = w.Sum(e => e.i) };