Table of Contents

Class WatermarkedSlidingWindowCollection<T>

Namespace
Scaleout.Streaming.TimeWindowing
Assembly
Scaleout.Streaming.TimeWindowing.dll

Iterable collection of time windows that are generated from an underlying collection of elements.

public class WatermarkedSlidingWindowCollection<T> : IEnumerable<ITimeWindow<T>>, IEnumerable

Type Parameters

T

The type of elements in the collection.

Inheritance
WatermarkedSlidingWindowCollection<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 sliding window algorithm. The collection also supports watermark-based closure of time windows and eviction of old elements from the underlying collection.

Constructors

WatermarkedSlidingWindowCollection(ICollection<T>, Func<T, DateTime>, TimeSpan, TimeSpan, DateTime, Func<DateTime, DateTime>)

Constructor.

public WatermarkedSlidingWindowCollection(ICollection<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, TimeSpan every, DateTime startTime, Func<DateTime, DateTime> watermarkGenerator)

Parameters

source ICollection<T>

An enumerable collection of elements to wrap with the transformation.

timestampSelector Func<T, DateTime>

A function to extract a timestamp from an element.

windowDuration TimeSpan

Duration of each time window. This is a maximum value that will be shortened for the last window(s) in the returned sequence (see remarks).

every TimeSpan

The period of time between the start of each sliding window.

startTime DateTime

Start time (inclusive) of the first sliding window.

watermarkGenerator Func<DateTime, DateTime>

A function to generate a watermark. Entries that arrive before the watermark time are evicted.

WatermarkedSlidingWindowCollection(ICollection<T>, Func<T, DateTime>, TimeSpan, TimeSpan, DateTime, Func<DateTime, DateTime>, DateTime)

Constructor.

public WatermarkedSlidingWindowCollection(ICollection<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, TimeSpan every, DateTime startTime, Func<DateTime, DateTime> watermarkGenerator, DateTime currentWatermark)

Parameters

source ICollection<T>

An enumerable collection of elements to wrap with the transformation.

timestampSelector Func<T, DateTime>

A function to extract a timestamp from an element.

windowDuration TimeSpan

Duration of each time window. This is a maximum value that will be shortened for the last window(s) in the returned sequence (see remarks).

every TimeSpan

The period of time between the start of each sliding window.

startTime DateTime

Start time (inclusive) of the first sliding window.

watermarkGenerator Func<DateTime, DateTime>

A function to generate a watermark. Entries that arrive before the watermark time are evicted.

currentWatermark DateTime

The current watermark time.

Properties

CurrentWatermark

public DateTime CurrentWatermark { get; }

Property Value

DateTime

Every

public TimeSpan Every { get; }

Property Value

TimeSpan

Items

public IReadOnlyCollection<T> Items { get; }

Property Value

IReadOnlyCollection<T>

StartTime

public DateTime StartTime { get; }

Property Value

DateTime

WindowDuration

public TimeSpan WindowDuration { get; }

Property Value

TimeSpan

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

item T

The element to add to the collection.

Returns

IEnumerable<ITimeWindow<T>>

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.