Show / Hide Table of Contents

Class SlidingWindowCollection<T>

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 chronologial order and evicted according to the startTime policy provided to the constructor.

Inheritance
System.Object
SlidingWindowCollection<T>
Implements
System.Collections.Generic.IEnumerable<ITimeWindow<T>>
System.Collections.IEnumerable
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Scaleout.Streaming.TimeWindowing
Assembly: Scaleout.Streaming.TimeWindowing.dll
Syntax
public class SlidingWindowCollection<T> : IEnumerable<ITimeWindow<T>>, IEnumerable
Type Parameters
Name Description
T

The type of objects in the source collection.

Constructors

| Improve this Doc View Source

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

Constructor.

Declaration
public SlidingWindowCollection(IList<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, TimeSpan every, DateTime startTime)
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 windowDuration

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).

System.TimeSpan every

The period of time between the start of each sliding window.

System.DateTime startTime

Start time (inclusive) of the first sliding window. Items in the underlying collection that fall before this start time will be evicted.

| Improve this Doc View Source

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

Constructor.

Declaration
public SlidingWindowCollection(LinkedList<T> source, Func<T, DateTime> timestampSelector, TimeSpan windowDuration, TimeSpan every, DateTime startTime)
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 windowDuration

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).

System.TimeSpan every

The period of time between the start of each sliding window.

System.DateTime startTime

Start time (inclusive) of the first sliding window. Items in the underlying collection that fall before this start time will be evicted.

Methods

| Improve this Doc View Source

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.

Declaration
public void Add(T item)
Parameters
Type Name Description
T item

The element to add to the collection.

| Improve this Doc View Source

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.

Explicit Interface Implementations

| Improve this Doc View Source

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

Implements

System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

SessionWindowExtensions.ToSessionWindows<TSource>(IEnumerable<TSource>, Func<TSource, DateTime>, TimeSpan)
SlidingWindowExtensions.ToSlidingWindows<TSource>(IEnumerable<TSource>, Func<TSource, DateTime>, DateTime, DateTime, TimeSpan, TimeSpan)
TumblingWindowExtensions.ToTumblingWindows<TSource>(IEnumerable<TSource>, Func<TSource, DateTime>, DateTime, DateTime, TimeSpan)
  • Improve this Doc
  • View Source
Back to top Copyright © 2017-2018 ScaleOut Software, Inc.