public override void Update(EventBean[] newData, EventBean[] oldData) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QViewProcessIRStream(this, _dataWindowViewFactory.ViewName, newData, oldData); } // add data points to the window if (newData != null) { foreach (EventBean newEvent in newData) { var pair = new ExpressionWindowTimestampEventPair(AgentInstanceContext.TimeProvider.Time, newEvent); _window.Add(pair); InternalHandleAdd(pair); } if (AggregationService != null) { AggregationService.ApplyEnter(newData, null, AgentInstanceContext); } } if (oldData != null) { _window.RemoveWhere( pair => oldData.Any(anOldData => pair.TheEvent == anOldData), pair => InternalHandleRemoved(pair)); if (AggregationService != null) { AggregationService.ApplyLeave(oldData, null, AgentInstanceContext); } } // expire events Expire(newData, oldData); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewProcessIRStream(); } }
private bool CheckEvent(ExpressionWindowTimestampEventPair first, ExpressionWindowTimestampEventPair newest, int numExpired) { ExpressionViewOAFieldEnumExtensions.Populate(BuiltinEventProps.Properties, _window.Count, first.Timestamp, newest.Timestamp, this, numExpired, first.TheEvent, newest.TheEvent); EventsPerStream[0] = first.TheEvent; foreach (AggregationServiceAggExpressionDesc aggregateNode in AggregateNodes) { aggregateNode.AssignFuture(AggregationService); } var result = ExpiryExpression.Evaluate(new EvaluateParams(EventsPerStream, true, AgentInstanceContext)); if (result == null) { return(false); } return(true.Equals(result)); }
// Called based on schedule evaluation registered when a variable changes (new data is null). // Called when new data arrives. private void Expire(EventBean[] newData, EventBean[] oldData) { OneEventCollection expired = null; if (oldData != null) { expired = new OneEventCollection(); expired.Add(oldData); } int expiredCount = 0; if (!_window.IsEmpty()) { ExpressionWindowTimestampEventPair newest = _window.Last; while (true) { ExpressionWindowTimestampEventPair first = _window.First; bool pass = CheckEvent(first, newest, expiredCount); if (!pass) { if (expired == null) { expired = new OneEventCollection(); } EventBean removed = _window.RemoveFirst().TheEvent; expired.Add(removed); if (AggregationService != null) { _removedEvents[0] = removed; AggregationService.ApplyLeave(_removedEvents, null, AgentInstanceContext); } expiredCount++; InternalHandleExpired(first); } else { break; } if (_window.IsEmpty()) { if (AggregationService != null) { AggregationService.ClearResults(AgentInstanceContext); } break; } } } // Check for any events that get pushed out of the window EventBean[] expiredArr = null; if (expired != null) { expiredArr = expired.ToArray(); } // update event buffer for access by expressions, if any if (ViewUpdatedCollection != null) { ViewUpdatedCollection.Update(newData, expiredArr); } // If there are child views, call update method if (HasViews) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QViewIndicate(this, _dataWindowViewFactory.ViewName, newData, expiredArr); } UpdateChildren(newData, expiredArr); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewIndicate(); } } }
public void InternalHandleAdd(ExpressionWindowTimestampEventPair pair) { // no action required }