Show / Hide Table of Contents

Class SlidingWindowExtensions

Provides extension method for sliding window transformation of a collection.

Inheritance
System.Object
SlidingWindowExtensions
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.Linq
Assembly: Scaleout.Streaming.TimeWindowing.dll
Syntax
public static class SlidingWindowExtensions

Methods

| Improve this Doc View Source

ToSlidingWindows<TSource>(IEnumerable<TSource>, Func<TSource, DateTime>, DateTime, DateTime, TimeSpan, TimeSpan)

Transforms a collection into an enumerable collection of sliding windows. The source collection must be sorted chronologically.

Declaration
public static IEnumerable<ITimeWindow<TSource>> ToSlidingWindows<TSource>(this IEnumerable<TSource> source, Func<TSource, DateTime> timestampSelector, DateTime startTime, DateTime endTime, TimeSpan windowDuration, TimeSpan every)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TSource> source

The sequence of elements to transform.

System.Func<TSource, System.DateTime> timestampSelector

A function to extract a timestamp from an element.

System.DateTime startTime

Start time (inclusive) of the first sliding window.

System.DateTime endTime

End time (exclusive) for the last of sliding window(s).

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.

Returns
Type Description
System.Collections.Generic.IEnumerable<ITimeWindow<TSource>>

An enumerable set of ITimeWindow<TElement> collections.

Type Parameters
Name Description
TSource

The type of objects in the source collection.

Remarks

The method returns a sequence of overlapping ITimeWindow<TElement> elements, where each window is an enumerable collection of elements from the source collection whose timestamp falls within its specified range. The StartTime is inclusive and the EndTime is exclusive.

The last sliding windows returned by this method may have a shorter duration than what is specified by the windowDuration argument. This happens when the duration would cause the window to extend beyond the specified endTime. These trailing windows can be skipped by using a Linq Where() operation on the returned sequence to filters out windows with short durations.

  • Improve this Doc
  • View Source
Back to top Copyright © 2017-2018 ScaleOut Software, Inc.