Table of Contents

Class SlidingWindowCollection<T>

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

Transforms a collection into an enumerable collection of overlapping time 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 startTime policy provided to the constructor.

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

Type Parameters

T

The type of objects in the source collection.

Inheritance
SlidingWindowCollection<T>
Implements
Inherited Members
Extension Methods

Constructors

SlidingWindowCollection(IList<T>, Func<T, DateTime>, TimeSpan, TimeSpan, DateTime)

Constructor.

public SlidingWindowCollection(IList<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, TimeSpan every, DateTime startTime)

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.

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. Items in the underlying collection that fall before this start time will be evicted.

SlidingWindowCollection(LinkedList<T>, Func<T, DateTime>, TimeSpan, TimeSpan, DateTime)

Constructor.

public SlidingWindowCollection(LinkedList<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, TimeSpan every, DateTime startTime)

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.

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. Items in the underlying collection that fall before this start time will be evicted.

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 startTime provided to this transformation's constructor then the new element will be evicted immediately.

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.