/// <summary> /// Expands the view to use a time bound window. TimeInMillis bound windows are sliding windows that extend the /// specified time interval into the past based on the system time. Provide a time period as parameter. /// <para/> /// If batch is specified, then the window buffers events (tumbling window) and releases them /// after the given time interval has occurred. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="esperQuery">The esper query.</param> /// <param name="seconds">The seconds.</param> /// <param name="batched">if set to <c>true</c> [batched].</param> /// <returns></returns> public static EsperQuery <T> WithDuration <T>(this EsperQuery <T> esperQuery, int seconds, bool batched = false) { return(WithDuration(esperQuery, TimeSpan.FromSeconds(seconds), batched)); }
/// <summary> /// Expands the view to use a time-accumulating. This data window view is a specialized moving (sliding) /// time window that differs from the regular time window in that it accumulates events until no more events /// arrive within a given time interval, and only then releases the accumulated events as a remove stream. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="esperQuery">The esper query.</param> /// <param name="timeSpan">The time span.</param> /// <returns></returns> public static EsperQuery <T> WithAccumlation <T>(this EsperQuery <T> esperQuery, TimeSpan timeSpan) { var timePeriodExpression = timeSpan.ToTimePeriodExpression(); return(esperQuery.FilterView(() => View.Create("time_accum", timePeriodExpression))); }
/// <summary> /// Expands the view to keep events (tumbling window) until the given expression is satisfied. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="esperQuery">The esper query.</param> /// <param name="expression">The expression.</param> /// <returns></returns> public static EsperQuery <T> KeepUntil <T>(this EsperQuery <T> esperQuery, System.Linq.Expressions.Expression <Func <T, bool> > expression) { return(esperQuery.FilterView(() => View.Create("win", "expr_batch", LinqToSoda.LinqToSodaExpression(expression)))); }
/// <summary> /// Expands the view to keep all events. The view does not remove events from the /// data window, unless used with a named window and the on delete clause. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="esperQuery">The esper query.</param> /// <returns></returns> public static EsperQuery <T> KeepAll <T>(this EsperQuery <T> esperQuery) { return(esperQuery.FilterView(() => View.Create("win", "keepall"))); }
/// <summary> /// Expands the view to keep events that occur within the specified duration. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="esperQuery">The esper query.</param> /// <param name="duration">The duration.</param> /// <returns></returns> public static EsperQuery <T> KeepFirst <T>(this EsperQuery <T> esperQuery, TimeSpan duration) { var timePeriodExpression = duration.ToTimePeriodExpression(); return(esperQuery.FilterView(() => View.Create("win", "firsttime", timePeriodExpression))); }
/// <summary> /// Expands the view to keep the first Count events. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="esperQuery">The esper query.</param> /// <param name="length">The length.</param> /// <returns></returns> public static EsperQuery <T> KeepFirst <T>(this EsperQuery <T> esperQuery, int length) { return(esperQuery.FilterView(() => View.Create("win", "firstlength", new ConstantExpression(length)))); }
/// <summary> /// Creates a window. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="serviceProvider">The service provider.</param> /// <param name="windowName">Name of the window.</param> /// <param name="view">The view.</param> /// <param name="esperQuery">The esper query.</param> /// <returns></returns> public static EPStatement CreateWindow <T>(this EPServiceProvider serviceProvider, string windowName, View view, EsperQuery <T> esperQuery) { return(CreateWindow(serviceProvider, windowName, view, esperQuery, null)); }
/// <summary> /// Selects the specified "item" from the esper query. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="esperQuery">The esper query.</param> /// <returns></returns> public static DisposableObservableCollection <T> Select <T>(this EsperQuery <T> esperQuery) { esperQuery.Compile(); return(esperQuery.Statement.AsObservableCollection <T>(true)); }
/// <summary> /// Generates a view that orders events that arrive out-of-order, using timestamp-values /// provided by an expression, and by comparing that timestamp value to engine system time. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="esperQuery">The esper query.</param> /// <param name="property">The property to use for the timestamp.</param> /// <param name="timePeriod">the time period specifying the time interval that an arriving event should maximally be held, in order to consider older events arriving at a later time</param> /// <returns></returns> /// <exception cref="System.ArgumentException">at least one property must be provided</exception> public static EsperQuery <T> TimeOrdered <T>(this EsperQuery <T> esperQuery, string property, TimeSpan timePeriod) { return(esperQuery.FilterView(() => View.Create("ext", "time_order", new PropertyValueExpression(property), timePeriod.ToTimePeriodExpression()))); }