Class TumblingWindowCollection<T>
- Namespace
- Scaleout.Streaming.TimeWindowing
- Assembly
- Scaleout.Streaming.TimeWindowing.dll
Transforms a collection into an enumerable collection of fixed-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 TumblingWindowCollection<T> : IEnumerable<ITimeWindow<T>>, IEnumerable
Type Parameters
TThe type of objects in the source collection.
- Inheritance
-
TumblingWindowCollection<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
TumblingWindowCollection(IList<T>, Func<T, DateTime>, TimeSpan, DateTime)
Constructor.
public TumblingWindowCollection(IList<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, DateTime startTime)
Parameters
sourceIList<T>The list of elements to wrap with the transformation.
timestampSelectorFunc<T, DateTime>A function to extract a timestamp from an element.
windowDurationTimeSpanDuration of each time window. This is a maximum value that may be shortened for the last window in the returned sequence.
startTimeDateTimeStart time (inclusive) of the first window. Items in the underlying collection that fall before this start time will be evicted.
TumblingWindowCollection(LinkedList<T>, Func<T, DateTime>, TimeSpan, DateTime)
Constructor.
public TumblingWindowCollection(LinkedList<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, DateTime startTime)
Parameters
sourceLinkedList<T>The linked list of elements to wrap with the transformation.
timestampSelectorFunc<T, DateTime>A function to extract a timestamp from an element.
windowDurationTimeSpanDuration of each time window. This is a maximum value that will be shortened for the last window in the returned sequence.
startTimeDateTimeStart time (inclusive) of the first 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
itemTThe 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.