public override void HandleMatching(EventBean[] triggerEvents, EventBean[] matchingEvents) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QInfraOnAction(OnTriggerType.ON_DELETE, triggerEvents, matchingEvents); } if ((matchingEvents != null) && (matchingEvents.Length > 0)) { // Events to delete are indicated via old data RootView.Update(null, matchingEvents); // The on-delete listeners receive the events deleted, but only if there is interest if (_parent.StatementResultService.IsMakeNatural || _parent.StatementResultService.IsMakeSynthetic) { UpdateChildren(matchingEvents, null); } } // Keep the last delete records _lastResult = matchingEvents; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraOnAction(); } }
public override void HandleMatching(EventBean[] triggerEvents, EventBean[] matchingEvents) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QInfraOnAction(OnTriggerType.ON_UPDATE, triggerEvents, matchingEvents); } if ((matchingEvents == null) || (matchingEvents.Length == 0)) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraOnAction(); } return; } var eventsPerStream = new EventBean[3]; var newData = new OneEventCollection(); var oldData = new OneEventCollection(); foreach (var triggerEvent in triggerEvents) { eventsPerStream[1] = triggerEvent; foreach (var matchingEvent in matchingEvents) { var copy = _parent.UpdateHelper.UpdateWCopy(matchingEvent, eventsPerStream, base.ExprEvaluatorContext); newData.Add(copy); oldData.Add(matchingEvent); } } if (!newData.IsEmpty()) { // Events to delete are indicated via old data RootView.Update(newData.ToArray(), oldData.ToArray()); // The on-delete listeners receive the events deleted, but only if there is interest if (_parent.StatementResultService.IsMakeNatural || _parent.StatementResultService.IsMakeSynthetic) { UpdateChildren(newData.ToArray(), oldData.ToArray()); } } // Keep the last delete records _lastResult = matchingEvents; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraOnAction(); } }
public override void HandleMatching(EventBean[] triggerEvents, EventBean[] matchingEvents) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QInfraOnAction(OnTriggerType.ON_SELECT, triggerEvents, matchingEvents); } EventBean[] newData; // clear state from prior results _resultSetProcessor.Clear(); // build join result // use linked hash set to retain order of join results for last/first/window to work most intuitively var newEvents = BuildJoinResult(triggerEvents, matchingEvents); // process matches var pair = _resultSetProcessor.ProcessJoinResult(newEvents, _oldEvents, false); newData = (pair != null ? pair.First : null); if (_parent.IsDistinct) { newData = EventBeanUtility.GetDistinctByProp(newData, _parent.EventBeanReader); } if (_tableStateInstanceInsertInto != null) { if (newData != null) { foreach (var aNewData in newData) { if (_audit) { AuditPath.AuditInsertInto(ExprEvaluatorContext.EngineURI, ExprEvaluatorContext.StatementName, aNewData); } _tableStateInstanceInsertInto.AddEventUnadorned(aNewData); } } } else if (_parent.InternalEventRouter != null) { if (newData != null) { foreach (var aNewData in newData) { if (_audit) { AuditPath.AuditInsertInto(ExprEvaluatorContext.EngineURI, ExprEvaluatorContext.StatementName, aNewData); } _parent.InternalEventRouter.Route(aNewData, _parent.StatementHandle, _parent.InternalEventRouteDest, ExprEvaluatorContext, _parent.IsAddToFront); } } } // The on-select listeners receive the events selected if ((newData != null) && (newData.Length > 0)) { // And post only if we have listeners/subscribers that need the data if (_parent.StatementResultService.IsMakeNatural || _parent.StatementResultService.IsMakeSynthetic) { UpdateChildren(newData, null); } } _lastResult = newData; // clear state from prior results _resultSetProcessor.Clear(); // Events to delete are indicated via old data if (_isDelete) { RootView.Update(null, matchingEvents); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraOnAction(); } }
public override void HandleMatching(EventBean[] triggerEvents, EventBean[] matchingEvents) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QInfraOnAction(OnTriggerType.ON_MERGE, triggerEvents, matchingEvents); } var newData = new OneEventCollection(); OneEventCollection oldData = null; var eventsPerStream = new EventBean[3]; // first:named window, second: trigger, third:before-update (optional) if ((matchingEvents == null) || (matchingEvents.Length == 0)) { var unmatched = _parent.NamedWindowOnMergeHelper.Unmatched; foreach (var triggerEvent in triggerEvents) { eventsPerStream[1] = triggerEvent; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QInfraMergeWhenThens(false, triggerEvent, unmatched.Count); } var count = -1; foreach (var action in unmatched) { count++; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QInfraMergeWhenThenItem(false, count); } if (!action.IsApplies(eventsPerStream, base.ExprEvaluatorContext)) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraMergeWhenThenItem(false, false); } continue; } action.Apply(null, eventsPerStream, newData, oldData, base.ExprEvaluatorContext); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraMergeWhenThenItem(false, true); } break; // apply no other actions } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraMergeWhenThens(false); } } } else { // handle update/ oldData = new OneEventCollection(); var matched = _parent.NamedWindowOnMergeHelper.Matched; foreach (var triggerEvent in triggerEvents) { eventsPerStream[1] = triggerEvent; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QInfraMergeWhenThens(true, triggerEvent, matched.Count); } foreach (var matchingEvent in matchingEvents) { eventsPerStream[0] = matchingEvent; var count = -1; foreach (var action in matched) { count++; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QInfraMergeWhenThenItem(true, count); } if (!action.IsApplies(eventsPerStream, base.ExprEvaluatorContext)) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraMergeWhenThenItem(true, false); } continue; } action.Apply(matchingEvent, eventsPerStream, newData, oldData, base.ExprEvaluatorContext); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraMergeWhenThenItem(true, true); } break; // apply no other actions } } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraMergeWhenThens(true); } } } if (!newData.IsEmpty() || (oldData != null && !oldData.IsEmpty())) { if ((MetricReportingPath.IsMetricsEnabled) && (_parent.CreateNamedWindowMetricHandle.IsEnabled) && !newData.IsEmpty()) { _parent.MetricReportingService.AccountTime(_parent.CreateNamedWindowMetricHandle, 0, 0, newData.ToArray().Length); } // Events to delete are indicated via old data // The on-merge listeners receive the events deleted, but only if there is interest if (_parent.StatementResultService.IsMakeNatural) { var eventsPerStreamNaturalNew = newData.IsEmpty() ? null : newData.ToArray(); var eventsPerStreamNaturalOld = (oldData == null || oldData.IsEmpty()) ? null : oldData.ToArray(); RootView.Update(EventBeanUtility.Denaturalize(eventsPerStreamNaturalNew), EventBeanUtility.Denaturalize(eventsPerStreamNaturalOld)); UpdateChildren(eventsPerStreamNaturalNew, eventsPerStreamNaturalOld); } else { var eventsPerStreamNew = newData.IsEmpty() ? null : newData.ToArray(); var eventsPerStreamOld = (oldData == null || oldData.IsEmpty()) ? null : oldData.ToArray(); RootView.Update(eventsPerStreamNew, eventsPerStreamOld); if (_parent.StatementResultService.IsMakeSynthetic) { UpdateChildren(eventsPerStreamNew, eventsPerStreamOld); } } } // Keep the last delete records _lastResult = matchingEvents; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AInfraOnAction(); } }