Table of Contents

Class SessionWindowCollection<T>

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

Transforms a collection into an enumerable collection of session windows and manages eviction of old items from the source collection. This wrapper can be used to manage the retention policy of the underlying collection. Objects added through this wrapper are inserted in chronological order and evicted according to the policy provided to the constructor.

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

Type Parameters

T

The type of objects in the source collection.

Inheritance
SessionWindowCollection<T>
Implements
Inherited Members
Extension Methods

Constructors

SessionWindowCollection(IList<T>, Func<T, DateTime>, TimeSpan, int)

Constructor

public SessionWindowCollection(IList<T> source, Func<T, DateTime> timestampSelector, TimeSpan idleThreshold, int boundedSessionCapacity)

Parameters

source IList<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.

boundedSessionCapacity int

Maximum number of sessions to retain. If a new element is added via the Add(T) method that creates a new session, elements in the oldest session will be evicted from the underlying collection.

SessionWindowCollection(LinkedList<T>, Func<T, DateTime>, TimeSpan, int)

Constructor

public SessionWindowCollection(LinkedList<T> source, Func<T, DateTime> timestampSelector, TimeSpan idleThreshold, int boundedSessionCapacity)

Parameters

source LinkedList<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.

boundedSessionCapacity int

Maximum number of sessions to retain. If a new element is added via the Add(T) method that creates a new session, elements in the oldest session will be evicted from the underlying collection.

Properties

Source

Gets a reference to the transformation's underlying collection.

public IEnumerable<T> Source { get; }

Property Value

IEnumerable<T>

Methods

Add(T)

Adds an element to the underlying collection, inserting it in chronological order and evicting old sessions if needed.

public void Add(T item)

Parameters

item T

The element to add to the collection.

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.

Refresh(bool)

Refreshes the transformation. For use when the underlying collection is modified directly instead of through this SessionWindowCollection<T> wrapper.

public void Refresh(bool performEviction)

Parameters

performEviction bool

Indicates that eviction should be re-run to remove elements from older session windows.