Class SessionWindowCollection<T>
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 chronologial order and evicted according to the policy provided to the constructor.
Inheritance
Inherited Members
Namespace: Scaleout.Streaming.TimeWindowing
Assembly: Scaleout.Streaming.TimeWindowing.dll
Syntax
public class SessionWindowCollection<T> : IEnumerable<ITimeWindow<T>>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | The type of objects in the source collection. |
Constructors
| Improve this Doc View SourceSessionWindowCollection(IList<T>, Func<T, DateTime>, TimeSpan, Int32)
Constructor
Declaration
public SessionWindowCollection(IList<T> source, Func<T, DateTime> timestampSelector, TimeSpan idleThreshold, int boundedSessionCapacity)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<T> | source | The list of elements to wrap with the transformation. |
System.Func<T, System.DateTime> | timestampSelector | A function to extract a timestamp from an element. |
System.TimeSpan | idleThreshold | Maximum allowed time gap between elements before a new session window is started. |
System.Int32 | boundedSessionCapacity | 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, Int32)
Constructor
Declaration
public SessionWindowCollection(LinkedList<T> source, Func<T, DateTime> timestampSelector, TimeSpan idleThreshold, int boundedSessionCapacity)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.LinkedList<T> | source | The linked list of elements to wrap with the transformation. |
System.Func<T, System.DateTime> | timestampSelector | A function to extract a timestamp from an element. |
System.TimeSpan | idleThreshold | Maximum allowed time gap between elements before a new session window is started. |
System.Int32 | boundedSessionCapacity | 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
| Improve this Doc View SourceSource
Gets a reference to the transformation's underlying collection.
Declaration
public IEnumerable<T> Source { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> |
Methods
| Improve this Doc View SourceAdd(T)
Adds an element to the underlying collection, inserting it in chronological order and evicting old sessions if needed.
Declaration
public void Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The element to add to the collection. |
GetEnumerator()
Returns an enumerator that iterates through the collection of time windows.
Declaration
public IEnumerator<ITimeWindow<T>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<ITimeWindow<T>> | An enumerator that can be used to iterate through the collection of ITimeWindow<TElement> elements. |
Refresh(Boolean)
Refreshes the transformation. For use when the underlying collection is modified directly instead of through this SessionWindowCollection<T> wrapper.
Declaration
public void Refresh(bool performEviction)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | performEviction | Indicates that eviction should be re-run to remove elements from older session windows. |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |