Table of Contents

Class WatermarkedSessionWindowCollection<T>

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

Transforms a collection into an enumerable collection of session windows. The collection also supports watermark-based closure of time windows and eviction of old elements from the underlying collection.

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

Type Parameters

T

The type of elements in the collection.

Inheritance
WatermarkedSessionWindowCollection<T>
Implements
Inherited Members
Extension Methods

Constructors

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

Constructor

public WatermarkedSessionWindowCollection(ICollection<T> source, Func<T, DateTime> timestampSelector, TimeSpan idleThreshold, Func<DateTime, DateTime> watermarkGenerator)

Parameters

source ICollection<T>

The list of elements to wrap with the transformation.

timestampSelector Func<T, DateTime>

A function to extract a timestamp from an element.

idleThreshold TimeSpan

Maximum allowed time gap between elements before a new session window is started.

watermarkGenerator Func<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.

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

Constructor

public WatermarkedSessionWindowCollection(ICollection<T> source, Func<T, DateTime> timestampSelector, TimeSpan idleThreshold, Func<DateTime, DateTime> watermarkGenerator, DateTime currentWatermark)

Parameters

source ICollection<T>

The linked list of elements to wrap with the transformation.

timestampSelector Func<T, DateTime>

A function to extract a timestamp from an element.

idleThreshold TimeSpan

Maximum allowed time gap between elements before a new session window is started.

watermarkGenerator Func<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.

currentWatermark DateTime

The current watermark time.

Properties

CurrentWatermark

public DateTime CurrentWatermark { get; }

Property Value

DateTime

IdleThreshold

public TimeSpan IdleThreshold { get; }

Property Value

TimeSpan

Items

public IReadOnlyCollection<T> Items { get; }

Property Value

IReadOnlyCollection<T>

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.