internal IRDescEntry(InternalEventRouterDesc internalEventRouterDesc, InternalRoutePreprocessView outputView, IReaderWriterLock agentInstanceLock, bool hasSubselect) { _internalEventRouterDesc = internalEventRouterDesc; _outputView = outputView; _agentInstanceLock = agentInstanceLock; _hasSubselect = hasSubselect; }
/// <summary> /// Ctor. /// </summary> /// <param name="priority">priority of statement</param> /// <param name="drop">whether to drop the event if matched</param> /// <param name="optionalWhereClause">where clause, or null if none provided</param> /// <param name="assignments">event property assignments</param> /// <param name="writer">writes values to an event</param> /// <param name="wideners">for widening types to write</param> /// <param name="outputView">for indicating output</param> /// <param name="agentInstanceLock">The agent instance lock.</param> /// <param name="hasSubselect">if set to <c>true</c> [has subselect].</param> public InternalEventRouterEntry(int priority, bool drop, ExprNode optionalWhereClause, ExprNode[] assignments, EventBeanWriter writer, TypeWidener[] wideners, InternalRoutePreprocessView outputView, IReaderWriterLock agentInstanceLock, bool hasSubselect) { Priority = priority; IsDrop = drop; OptionalWhereClause = optionalWhereClause == null ? null : optionalWhereClause.ExprEvaluator; Assignments = ExprNodeUtility.GetEvaluators(assignments); Writer = writer; Wideners = wideners; OutputView = outputView; AgentInstanceLock = agentInstanceLock; HasSubselect = hasSubselect; }
public void AddPreprocessing(InternalEventRouterDesc internalEventRouterDesc, InternalRoutePreprocessView outputView, IReaderWriterLock agentInstanceLock, bool hasSubselect) { _descriptors.Put(internalEventRouterDesc.UpdateDesc, new IRDescEntry(internalEventRouterDesc, outputView, agentInstanceLock, hasSubselect)); // remove all preprocessors for this type as well as any known child types, forcing re-init on next use RemovePreprocessors(internalEventRouterDesc.EventType); _hasPreprocessing = true; }
/// <summary> /// Pre-proces the event. /// </summary> /// <param name="theEvent">to pre-process</param> /// <param name="exprEvaluatorContext">expression evaluation context</param> /// <returns> /// processed event /// </returns> public EventBean Process(EventBean theEvent, ExprEvaluatorContext exprEvaluatorContext) { if (_empty) { return(theEvent); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QUpdateIStream(_entries); } EventBean oldEvent = theEvent; bool haveCloned = false; var eventsPerStream = new EventBean[1]; eventsPerStream[0] = theEvent; InternalEventRouterEntry lastEntry = null; for (int i = 0; i < _entries.Length; i++) { InternalEventRouterEntry entry = _entries[i]; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QUpdateIStreamApply(i, entry); } ExprEvaluator whereClause = entry.OptionalWhereClause; if (whereClause != null) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QUpdateIStreamApplyWhere(); } var result = whereClause.Evaluate(new EvaluateParams(eventsPerStream, true, exprEvaluatorContext)); if ((result == null) || (false.Equals(result))) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AUpdateIStreamApplyWhere((bool?)result); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AUpdateIStreamApply(null, false); } continue; } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AUpdateIStreamApplyWhere(true); } } if (entry.IsDrop) { return(null); } // before applying the changes, indicate to last-entries output view if (lastEntry != null) { InternalRoutePreprocessView view = lastEntry.OutputView; if (view.IsIndicate) { EventBean copied = _copyMethod.Copy(theEvent); view.Indicate(copied, oldEvent); oldEvent = copied; } else { if (_entries[i].OutputView.IsIndicate) { oldEvent = _copyMethod.Copy(theEvent); } } } // copy event for the first Update that applies if (!haveCloned) { EventBean copiedEvent = _copyMethod.Copy(theEvent); if (copiedEvent == null) { Log.Warn("Event of type " + theEvent.EventType.Name + " could not be copied"); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AUpdateIStreamApply(null, false); } return(null); } haveCloned = true; eventsPerStream[0] = copiedEvent; theEvent = copiedEvent; } Apply(theEvent, eventsPerStream, entry, exprEvaluatorContext); lastEntry = entry; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AUpdateIStreamApply(theEvent, true); } } if (lastEntry != null) { InternalRoutePreprocessView view = lastEntry.OutputView; if (view.IsIndicate) { view.Indicate(theEvent, oldEvent); } } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AUpdateIStream(theEvent, haveCloned); } return(theEvent); }