Class WatermarkedTumblingWindowCollection<T>
- Namespace
- Scaleout.Streaming.TimeWindowing
- Assembly
- Scaleout.Streaming.TimeWindowing.dll
A collection of tumbling time windows that are generated from a source collection of elements. Each window has a fixed duration and does not overlap with other windows.
public class WatermarkedTumblingWindowCollection<T> : IEnumerable<ITimeWindow<T>>, IEnumerable
Type Parameters
TThe type of elements in the collection.
- Inheritance
-
WatermarkedTumblingWindowCollection<T>
- Implements
- Inherited Members
- Extension Methods
Remarks
The underlying collection is expected to be ordered by timestamp, and the time windows are generated based on a tumbling window algorithm. The collection also supports watermark-based closure of time windows and eviction of old elements from the underlying collection.
Constructors
WatermarkedTumblingWindowCollection(ICollection<T>, Func<T, DateTime>, TimeSpan, DateTime, Func<DateTime, DateTime>)
Constructor.
public WatermarkedTumblingWindowCollection(ICollection<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, DateTime startTime, Func<DateTime, DateTime> watermarkGenerator)
Parameters
sourceICollection<T>The source collection of elements.
timestampSelectorFunc<T, DateTime>A function to extract the timestamp from each element.
windowDurationTimeSpanThe duration of each tumbling window.
startTimeDateTimeThe start time for the first window.
watermarkGeneratorFunc<DateTime, DateTime>A function to generate the watermark based on the time of the latest element added. Entries that arrive before the watermark time are evicted.
WatermarkedTumblingWindowCollection(ICollection<T>, Func<T, DateTime>, TimeSpan, DateTime, Func<DateTime, DateTime>, DateTime)
Constructor.
public WatermarkedTumblingWindowCollection(ICollection<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, DateTime startTime, Func<DateTime, DateTime> watermarkGenerator, DateTime currentWatermark)
Parameters
sourceICollection<T>The source collection of elements.
timestampSelectorFunc<T, DateTime>A function to extract the timestamp from each element.
windowDurationTimeSpanThe duration of each tumbling window.
startTimeDateTimeThe start time for the first window.
watermarkGeneratorFunc<DateTime, DateTime>A function to generate the watermark based on the time of the latest element added. Entries that arrive before the watermark time are evicted.
currentWatermarkDateTimeThe current watermark time.
Properties
CurrentWatermark
public DateTime CurrentWatermark { get; }
Property Value
Items
public IReadOnlyCollection<T> Items { get; }
Property Value
StartTime
public DateTime StartTime { get; }
Property Value
WindowDuration
public TimeSpan WindowDuration { get; }
Property Value
Methods
Add(T)
Adds an element to the underlying collection, inserting it into the underlying source collection in chronological order. If the timestamp associated with the new element falls before the collection's current watermark provided to this transformation's constructor then the new element will be evicted immediately.
public IEnumerable<ITimeWindow<T>> Add(T item)
Parameters
itemTThe element to add to the collection.
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection of time windows.
public IEnumerator<ITimeWindow<T>> GetEnumerator()
Returns
- IEnumerator<ITimeWindow<T>>
An enumerator that can be used to iterate through the collection of ITimeWindow<TElement> elements.