public AgentInstanceViewFactoryChainContext(AgentInstanceContext agentInstanceContext, bool isRemoveStream, Object previousNodeGetter, ViewUpdatedCollection priorViewUpdatedCollection) { _agentInstanceContext = agentInstanceContext; _isRemoveStream = isRemoveStream; _previousNodeGetter = previousNodeGetter; _priorViewUpdatedCollection = priorViewUpdatedCollection; }
/// <summary> /// Constructor. /// </summary> /// <param name="timeBatchViewFactory">for copying this view in a group-by</param> /// <param name="agentInstanceContext">The agent instance context.</param> /// <param name="timeDeltaComputation">is the number of milliseconds to batch events for</param> /// <param name="numberOfEvents">is the event count before the batch fires off</param> /// <param name="forceOutput">is true if the batch should produce empty output if there is no value to output following time intervals</param> /// <param name="isStartEager">is true for start-eager</param> /// <param name="viewUpdatedCollection">is a collection that the view must Update when receiving events</param> public TimeLengthBatchView( TimeLengthBatchViewFactory timeBatchViewFactory, AgentInstanceViewFactoryChainContext agentInstanceContext, ExprTimePeriodEvalDeltaConst timeDeltaComputation, long numberOfEvents, bool forceOutput, bool isStartEager, ViewUpdatedCollection viewUpdatedCollection) { _agentInstanceContext = agentInstanceContext; _timeLengthBatchViewFactory = timeBatchViewFactory; _timeDeltaComputation = timeDeltaComputation; _numberOfEvents = numberOfEvents; _isStartEager = isStartEager; _viewUpdatedCollection = viewUpdatedCollection; _isForceOutput = forceOutput; _scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); // schedule the first callback if (isStartEager) { ScheduleCallback(0); } agentInstanceContext.AddTerminationCallback(Stop); }
public View MakeView(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext) { ViewUpdatedCollection randomAccess = agentInstanceViewFactoryContext.StatementContext.ViewServicePreviousFactory .GetOptPreviousExprRandomAccess(agentInstanceViewFactoryContext); return new KeepAllView(agentInstanceViewFactoryContext, this, randomAccess); }
/// <summary> /// Constructor. /// </summary> /// <param name="timeBatchViewFactory">for copying this view in a group-by</param> /// <param name="agentInstanceContext">The agent instance context.</param> /// <param name="timeDeltaComputation">computes the number of milliseconds to batch events for</param> /// <param name="referencePoint">is the reference point onto which to base intervals, or null ifthere is no such reference point supplied</param> /// <param name="forceOutput">is true if the batch should produce empty output if there is no value to output following time intervals</param> /// <param name="isStartEager">is true for start-eager</param> /// <param name="viewUpdatedCollection">is a collection that the view must Update when receiving events</param> public TimeBatchView(TimeBatchViewFactory timeBatchViewFactory, AgentInstanceViewFactoryChainContext agentInstanceContext, ExprTimePeriodEvalDeltaConst timeDeltaComputation, long?referencePoint, bool forceOutput, bool isStartEager, ViewUpdatedCollection viewUpdatedCollection) { _agentInstanceContext = agentInstanceContext; _timeBatchViewFactory = timeBatchViewFactory; _timeDeltaComputation = timeDeltaComputation; _initialReferencePoint = referencePoint; _isStartEager = isStartEager; _viewUpdatedCollection = viewUpdatedCollection; _isForceOutput = forceOutput; _scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); // schedule the first callback if (isStartEager) { if (_currentReferencePoint == null) { _currentReferencePoint = agentInstanceContext.StatementContext.SchedulingService.Time; } ScheduleCallback(); _isCallbackScheduled = true; } agentInstanceContext.AddTerminationCallback(Stop); }
/// <summary> /// Ctor. /// </summary> /// <param name="agentInstanceViewFactoryContext">The agent instance view factory context.</param> /// <param name="keepAllViewFactory">for copying this view in a group-by</param> /// <param name="viewUpdatedCollection">for satisfying queries that select previous events in window order</param> public KeepAllView(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext, KeepAllViewFactory keepAllViewFactory, ViewUpdatedCollection viewUpdatedCollection) { AgentInstanceViewFactoryContext = agentInstanceViewFactoryContext; _keepAllViewFactory = keepAllViewFactory; _indexedEvents = new LinkedHashSet <EventBean>(); _viewUpdatedCollection = viewUpdatedCollection; }
/// <summary> /// Constructor. /// </summary> /// <param name="viewUpdatedCollection">is a collection that the view must update when receiving events</param> /// <param name="timeBatchViewFactory">fr copying this view in a group-by</param> /// <param name="agentInstanceContext">is required view services</param> /// <param name="timeDeltaComputation">delta computation</param> public TimeAccumView( TimeAccumViewFactory timeBatchViewFactory, AgentInstanceViewFactoryChainContext agentInstanceContext, ExprTimePeriodEvalDeltaConst timeDeltaComputation, ViewUpdatedCollection viewUpdatedCollection) { _agentInstanceContext = agentInstanceContext; _factory = timeBatchViewFactory; _timeDeltaComputation = timeDeltaComputation; _viewUpdatedCollection = viewUpdatedCollection; _scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); var callback = new ProxyScheduleHandleCallback { ProcScheduledTrigger = extensionServicesContext => { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QViewScheduledEval(this, _factory.ViewName); } SendRemoveStream(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewScheduledEval(); } } }; _handle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback); agentInstanceContext.AddTerminationCallback(this); }
/// <summary> /// Constructor. /// </summary> /// <param name="agentInstanceContext">The agent instance context.</param> /// <param name="timeWindowViewFactory">for copying the view in a group-by</param> /// <param name="timeDeltaComputation">is the computation of number of milliseconds before events gets pushedout of the timeWindow as oldData in the Update method.</param> /// <param name="viewUpdatedCollection">is a collection the view must Update when receiving events</param> public TimeWindowView( AgentInstanceViewFactoryChainContext agentInstanceContext, TimeWindowViewFactory timeWindowViewFactory, ExprTimePeriodEvalDeltaConst timeDeltaComputation, ViewUpdatedCollection viewUpdatedCollection) { _agentInstanceContext = agentInstanceContext; _timeWindowViewFactory = timeWindowViewFactory; _timeDeltaComputation = timeDeltaComputation; _viewUpdatedCollection = viewUpdatedCollection; _scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); _timeWindow = new TimeWindow(agentInstanceContext.IsRemoveStream); ScheduleHandleCallback callback = new ProxyScheduleHandleCallback { ProcScheduledTrigger = extensionServicesContext => Instrument.With( i => i.QViewScheduledEval(this, timeWindowViewFactory.ViewName), i => i.AViewScheduledEval(), Expire) }; _handle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback); if (agentInstanceContext.StatementContext.ScheduleAdjustmentService != null) { agentInstanceContext.StatementContext.ScheduleAdjustmentService.AddCallback(this); } agentInstanceContext.AddTerminationCallback(Stop); }
public TimeAccumView( TimeAccumViewFactory timeBatchViewFactory, AgentInstanceViewFactoryChainContext agentInstanceContext, ViewUpdatedCollection viewUpdatedCollection, TimePeriodProvide timePeriodProvide) { this.agentInstanceContext = agentInstanceContext.AgentInstanceContext; factory = timeBatchViewFactory; this.viewUpdatedCollection = viewUpdatedCollection; scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); this.timePeriodProvide = timePeriodProvide; ScheduleHandleCallback callback = new ProxyScheduleHandleCallback { ProcScheduledTrigger = () => { agentInstanceContext.AuditProvider.ScheduleFire( agentInstanceContext.AgentInstanceContext, ScheduleObjectType.view, factory.ViewName); agentInstanceContext.InstrumentationProvider.QViewScheduledEval(factory); SendRemoveStream(); agentInstanceContext.InstrumentationProvider.AViewScheduledEval(); } }; handle = new EPStatementHandleCallbackSchedule( agentInstanceContext.EpStatementAgentInstanceHandle, callback); }
public ExpressionBatchView( ExpressionBatchViewFactory factory, ViewUpdatedCollection viewUpdatedCollection, ObjectArrayEventBean builtinEventProps, AgentInstanceViewFactoryChainContext agentInstanceContext) : base(factory, viewUpdatedCollection, builtinEventProps, agentInstanceContext) { }
protected ExpressionViewBase( ViewUpdatedCollection viewUpdatedCollection, ExprEvaluator expiryExpression, AggregationServiceFactoryDesc aggregationServiceFactoryDesc, ObjectArrayEventBean builtinEventProps, ISet <String> variableNames, AgentInstanceViewFactoryChainContext agentInstanceContext) { ViewUpdatedCollection = viewUpdatedCollection; ExpiryExpression = expiryExpression; BuiltinEventProps = builtinEventProps; EventsPerStream = new EventBean[] { null, builtinEventProps }; VariableNames = variableNames; AgentInstanceContext = agentInstanceContext; if (variableNames != null && !variableNames.IsEmpty()) { foreach (String variable in variableNames) { var variableName = variable; var agentInstanceId = agentInstanceContext.AgentInstanceId; var variableService = agentInstanceContext.StatementContext.VariableService; agentInstanceContext.StatementContext.VariableService.RegisterCallback(variable, agentInstanceId, Update); agentInstanceContext.AddTerminationCallback( new ProxyStopCallback(() => variableService.UnregisterCallback(variableName, agentInstanceId, Update))); } ScheduleHandleCallback callback = new ProxyScheduleHandleCallback { ProcScheduledTrigger = extensionServicesContext => Instrument.With( i => i.QViewScheduledEval(this, ViewName), i => i.AViewScheduledEval(), ScheduleCallback) }; ScheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); ScheduleHandle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback); agentInstanceContext.AddTerminationCallback(this); } else { ScheduleSlot = -1; ScheduleHandle = null; } if (aggregationServiceFactoryDesc != null) { AggregationService = aggregationServiceFactoryDesc.AggregationServiceFactory.MakeService( agentInstanceContext.AgentInstanceContext, agentInstanceContext.AgentInstanceContext.StatementContext.EngineImportService, false, null); AggregateNodes = aggregationServiceFactoryDesc.Expressions; } else { AggregationService = null; AggregateNodes = Collections.GetEmptyList <AggregationServiceAggExpressionDesc>(); } }
public View MakeView(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext) { ExprTimePeriodEvalDeltaConst timeDeltaComputation = _timeDeltaComputationFactory.Make( ViewName, "view", agentInstanceViewFactoryContext.AgentInstanceContext); ViewUpdatedCollection randomAccess = agentInstanceViewFactoryContext.StatementContext.ViewServicePreviousFactory .GetOptPreviousExprRandomAccess(agentInstanceViewFactoryContext); return new TimeWindowView(agentInstanceViewFactoryContext, this, timeDeltaComputation, randomAccess); }
/// <summary> /// Constructor creates a moving window extending the specified number of elements into the past. /// </summary> /// <param name="dataWindowViewFactory">for copying this view in a group-by</param> /// <param name="viewUpdatedCollection">is a collection that the view must update when receiving events</param> /// <param name="expiryExpression">The expiry expression.</param> /// <param name="AggregationServiceFactoryDesc">The aggregation service factory desc.</param> /// <param name="builtinEventProps">The builtin event props.</param> /// <param name="variableNames">variable names</param> /// <param name="AgentInstanceContext">The agent instance context.</param> public ExpressionWindowView(ExpressionWindowViewFactory dataWindowViewFactory, ViewUpdatedCollection viewUpdatedCollection, ExprEvaluator expiryExpression, AggregationServiceFactoryDesc AggregationServiceFactoryDesc, ObjectArrayEventBean builtinEventProps, ISet <String> variableNames, AgentInstanceViewFactoryChainContext AgentInstanceContext) : base(viewUpdatedCollection, expiryExpression, AggregationServiceFactoryDesc, builtinEventProps, variableNames, AgentInstanceContext) { _dataWindowViewFactory = dataWindowViewFactory; }
public AgentInstanceViewFactoryChainContext( AgentInstanceContext agentInstanceContext, bool isRemoveStream, PreviousGetterStrategy previousNodeGetter, ViewUpdatedCollection priorViewUpdatedCollection) { AgentInstanceContext = agentInstanceContext; IsRemoveStream = isRemoveStream; PreviousNodeGetter = previousNodeGetter; PriorViewUpdatedCollection = priorViewUpdatedCollection; }
public ExternallyTimedWindowView( ExternallyTimedWindowViewFactory factory, ViewUpdatedCollection viewUpdatedCollection, AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext, TimePeriodProvide timePeriodProvide) { this.factory = factory; this.viewUpdatedCollection = viewUpdatedCollection; this.timeWindow = new TimeWindow(agentInstanceViewFactoryContext.IsRemoveStream); this.agentInstanceViewFactoryContext = agentInstanceViewFactoryContext; this.timePeriodProvide = timePeriodProvide; }
public ExternallyTimedBatchView( ExternallyTimedBatchViewFactory factory, ViewUpdatedCollection viewUpdatedCollection, AgentInstanceViewFactoryChainContext agentInstanceContext, TimePeriodProvide timePeriodProvide) { this.factory = factory; this.viewUpdatedCollection = viewUpdatedCollection; this.agentInstanceContext = agentInstanceContext.AgentInstanceContext; referenceTimestamp = factory.optionalReferencePoint; this.timePeriodProvide = timePeriodProvide; }
public static PriorEvalStrategy ToStrategy(AgentInstanceViewFactoryChainContext viewFactoryChainContext) { ViewUpdatedCollection priorViewUpdatedCollection = viewFactoryChainContext.PriorViewUpdatedCollection; if (priorViewUpdatedCollection is RandomAccessByIndex) { return new ExprPriorEvalStrategyRandomAccess((RandomAccessByIndex) priorViewUpdatedCollection); } if (priorViewUpdatedCollection is RelativeAccessByEventNIndex) { return new ExprPriorEvalStrategyRelativeAccess( (RelativeAccessByEventNIndex) priorViewUpdatedCollection); } return null; }
/// <summary> /// Constructor creates a moving window extending the specified number of elements into the past. /// </summary> /// <param name="agentInstanceContext">The agent instance context.</param> /// <param name="viewFactory">for copying this view in a group-by</param> /// <param name="size">is the specified number of elements into the past</param> /// <param name="viewUpdatedCollection">is a collection that the view must update when receiving events</param> /// <exception cref="ArgumentException">Illegal argument for size of length window</exception> public LengthWindowView( AgentInstanceViewFactoryChainContext agentInstanceContext, LengthWindowViewFactory viewFactory, int size, ViewUpdatedCollection viewUpdatedCollection) { if (size < 1) { throw new ArgumentException("Illegal argument for size of length window"); } this.agentInstanceContext = agentInstanceContext.AgentInstanceContext; this.viewFactory = viewFactory; Size = size; ViewUpdatedCollection = viewUpdatedCollection; }
/// <summary> /// Constructor. /// </summary> /// <param name="agentInstanceViewFactoryContext">The agent instance view factory context.</param> /// <param name="lengthBatchViewFactory">for copying this view in a group-by</param> /// <param name="size">is the number of events to batch</param> /// <param name="viewUpdatedCollection">is a collection that the view must Update when receiving events</param> public LengthBatchView(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext, LengthBatchViewFactory lengthBatchViewFactory, int size, ViewUpdatedCollection viewUpdatedCollection) { AgentInstanceViewFactoryContext = agentInstanceViewFactoryContext; _lengthBatchViewFactory = lengthBatchViewFactory; _size = size; _viewUpdatedCollection = viewUpdatedCollection; if (size <= 0) { throw new ArgumentException("Invalid size parameter, size=" + size); } }
public View MakeView(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext) { int size = ViewFactorySupport.EvaluateSizeParam( ViewName, _sizeEvaluator, agentInstanceViewFactoryContext.AgentInstanceContext); ViewUpdatedCollection viewUpdatedCollection = agentInstanceViewFactoryContext.StatementContext.ViewServicePreviousFactory .GetOptPreviousExprRelativeAccess(agentInstanceViewFactoryContext); if (agentInstanceViewFactoryContext.IsRemoveStream) { return new LengthBatchViewRStream(agentInstanceViewFactoryContext, this, size); } else { return new LengthBatchView(agentInstanceViewFactoryContext, this, size, viewUpdatedCollection); } }
/// <summary> /// Constructor. /// </summary> /// <param name="factory">for copying this view in a group-by</param> /// <param name="timestampExpression">is the field name containing a long timestamp valuethat should be in ascending order for the natural order of events and is intended to reflect /// System.currentTimeInMillis but does not necessarily have to. /// out of the window as oldData in the update method. The view compares /// each events timestamp against the newest event timestamp and those with a delta /// greater then secondsBeforeExpiry are pushed out of the window.</param> /// <param name="timestampExpressionEval">The timestamp expression eval.</param> /// <param name="timeDeltaComputation">The time delta computation.</param> /// <param name="optionalReferencePoint">The optional reference point.</param> /// <param name="viewUpdatedCollection">is a collection that the view must update when receiving events</param> /// <param name="agentInstanceViewFactoryContext">context for expression evalauation</param> public ExternallyTimedBatchView(ExternallyTimedBatchViewFactory factory, ExprNode timestampExpression, ExprEvaluator timestampExpressionEval, ExprTimePeriodEvalDeltaConst timeDeltaComputation, long?optionalReferencePoint, ViewUpdatedCollection viewUpdatedCollection, AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext) { _factory = factory; _timestampExpression = timestampExpression; _timestampExpressionEval = timestampExpressionEval; _timeDeltaComputation = timeDeltaComputation; ViewUpdatedCollection = viewUpdatedCollection; AgentInstanceViewFactoryContext = agentInstanceViewFactoryContext; ReferenceTimestamp = optionalReferencePoint; }
/// <summary> /// Constructor. /// </summary> /// <param name="externallyTimedWindowViewFactory">for copying this view in a group-by</param> /// <param name="timestampExpression">is the field name containing a long timestamp valuethat should be in ascending order for the natural order of /// events and is intended to reflect /// System.currentTimeInMillis but does not necessarily have to. /// out of the window as oldData in the update method. The view compares /// each events timestamp against the newest event timestamp and those with a delta /// greater then secondsBeforeExpiry are pushed out of the window.</param> /// <param name="timestampExpressionEval">The timestamp expression eval.</param> /// <param name="timeDeltaComputation">The time delta computation.</param> /// <param name="viewUpdatedCollection">is a collection that the view must update when receiving events</param> /// <param name="agentInstanceViewFactoryContext">context for expression evalauation</param> public ExternallyTimedWindowView( ExternallyTimedWindowViewFactory externallyTimedWindowViewFactory, ExprNode timestampExpression, ExprEvaluator timestampExpressionEval, ExprTimePeriodEvalDeltaConst timeDeltaComputation, ViewUpdatedCollection viewUpdatedCollection, AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext) { _externallyTimedWindowViewFactory = externallyTimedWindowViewFactory; _timestampExpression = timestampExpression; _timestampExpressionEval = timestampExpressionEval; _timeDeltaComputation = timeDeltaComputation; _viewUpdatedCollection = viewUpdatedCollection; _timeWindow = new TimeWindow(agentInstanceViewFactoryContext.IsRemoveStream); AgentInstanceViewFactoryContext = agentInstanceViewFactoryContext; }
public View MakeView(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext) { ExprTimePeriodEvalDeltaConst timeDeltaComputation = _timeDeltaComputationFactory.Make( ViewName, "view", agentInstanceViewFactoryContext.AgentInstanceContext); ViewUpdatedCollection randomAccess = agentInstanceViewFactoryContext.StatementContext.ViewServicePreviousFactory .GetOptPreviousExprRandomAccess(agentInstanceViewFactoryContext); if (agentInstanceViewFactoryContext.IsRemoveStream) { return(new TimeAccumViewRStream(this, agentInstanceViewFactoryContext, timeDeltaComputation)); } else { return(new TimeAccumView(this, agentInstanceViewFactoryContext, timeDeltaComputation, randomAccess)); } }
public TimeLengthBatchView( TimeLengthBatchViewFactory factory, int size, AgentInstanceViewFactoryChainContext agentInstanceContext, ViewUpdatedCollection viewUpdatedCollection, TimePeriodProvide timePeriodProvide) { this.agentInstanceContext = agentInstanceContext.AgentInstanceContext; this.factory = factory; this.size = size; this.viewUpdatedCollection = viewUpdatedCollection; scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); this.timePeriodProvide = timePeriodProvide; // schedule the first callback if (factory.IsStartEager) { ScheduleCallback(0); } }
public View MakeView(AgentInstanceViewFactoryChainContext agentInstanceViewFactoryContext) { ExprTimePeriodEvalDeltaConst timeDeltaComputation = timeDeltaComputationFactory.Make( ViewName, "view", agentInstanceViewFactoryContext.AgentInstanceContext); ViewUpdatedCollection viewUpdatedCollection = agentInstanceViewFactoryContext.StatementContext.ViewServicePreviousFactory .GetOptPreviousExprRelativeAccess(agentInstanceViewFactoryContext); if (agentInstanceViewFactoryContext.IsRemoveStream) { return(new TimeBatchViewRStream( this, agentInstanceViewFactoryContext, timeDeltaComputation, _optionalReferencePoint, IsForceUpdate, IsStartEager)); } else { return(new TimeBatchView( this, agentInstanceViewFactoryContext, timeDeltaComputation, _optionalReferencePoint, IsForceUpdate, IsStartEager, viewUpdatedCollection)); } }
public TimeBatchView( TimeBatchViewFactory factory, AgentInstanceViewFactoryChainContext agentInstanceContext, ViewUpdatedCollection viewUpdatedCollection, TimePeriodProvide timePeriodProvide) { _agentInstanceContext = agentInstanceContext.AgentInstanceContext; _factory = factory; _viewUpdatedCollection = viewUpdatedCollection; _scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); _timePeriodProvide = timePeriodProvide; // schedule the first callback if (factory.isStartEager) { if (_currentReferencePoint == null) { _currentReferencePoint = agentInstanceContext.StatementContext.SchedulingService.Time; } ScheduleCallback(); _isCallbackScheduled = true; } }
/// <summary> /// Constructor. /// </summary> /// <param name="timeBatchViewFactory">fr copying this view in a group-by</param> /// <param name="agentInstanceContext">is required view services</param> /// <param name="timeDeltaComputation">The time delta computation.</param> /// <param name="viewUpdatedCollection">is a collection that the view must Update when receiving events</param> public TimeAccumView( TimeAccumViewFactory timeBatchViewFactory, AgentInstanceViewFactoryChainContext agentInstanceContext, ExprTimePeriodEvalDeltaConst timeDeltaComputation, ViewUpdatedCollection viewUpdatedCollection) { AgentInstanceContext = agentInstanceContext; _factory = timeBatchViewFactory; _timeDeltaComputation = timeDeltaComputation; ViewUpdatedCollection = viewUpdatedCollection; ScheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); ScheduleHandleCallback callback = new ProxyScheduleHandleCallback { ProcScheduledTrigger = extensionServicesContext => Instrument.With( i => i.QViewScheduledEval(this, _factory.ViewName), i => i.AViewScheduledEval(), SendRemoveStream) }; Handle = new EPStatementHandleCallback(agentInstanceContext.EpStatementAgentInstanceHandle, callback); agentInstanceContext.AddTerminationCallback(Stop); }
private static void HandlePrior(ViewUpdatedCollection viewUpdatedCollection, IDictionary <int, IList <ExprPriorNode> > callbacksPerIndex, IDictionary <ExprPriorNode, ExprPriorEvalStrategy> strategies) { // Since an expression such as "prior(2, price), prior(8, price)" translates // into {2, 8} the relative index is {0, 1}. // Map the expression-supplied index to a relative viewUpdatedCollection-known index via wrapper var relativeIndex = 0; foreach (var reqIndex in callbacksPerIndex.Keys) { var priorNodes = callbacksPerIndex.Get(reqIndex); foreach (var callback in priorNodes) { ExprPriorEvalStrategy strategy; if (viewUpdatedCollection is RelativeAccessByEventNIndex) { var relativeAccess = (RelativeAccessByEventNIndex)viewUpdatedCollection; var impl = new PriorEventViewRelAccess(relativeAccess, relativeIndex); strategy = new ExprPriorEvalStrategyRelativeAccess(impl); } else { if (viewUpdatedCollection is RandomAccessByIndex) { strategy = new ExprPriorEvalStrategyRandomAccess((RandomAccessByIndex)viewUpdatedCollection); } else { strategy = new ExprPriorEvalStrategyRelativeAccess((RelativeAccessByEventNIndex)viewUpdatedCollection); } } strategies.Put(callback, strategy); } relativeIndex++; } }
public static AgentInstanceViewFactoryChainContext Create(IList <ViewFactory> viewFactoryChain, AgentInstanceContext agentInstanceContext, ViewResourceDelegateVerifiedStream viewResourceDelegate) { Object previousNodeGetter = null; if (viewResourceDelegate.PreviousRequests != null && !viewResourceDelegate.PreviousRequests.IsEmpty()) { DataWindowViewWithPrevious factoryFound = EPStatementStartMethodHelperPrevious.FindPreviousViewFactory(viewFactoryChain); previousNodeGetter = factoryFound.MakePreviousGetter(); } ViewUpdatedCollection priorViewUpdatedCollection = null; if (viewResourceDelegate.PriorRequests != null && !viewResourceDelegate.PriorRequests.IsEmpty()) { var priorEventViewFactory = EPStatementStartMethodHelperPrior.FindPriorViewFactory(viewFactoryChain); var callbacksPerIndex = viewResourceDelegate.PriorRequests; priorViewUpdatedCollection = priorEventViewFactory.MakeViewUpdatedCollection(callbacksPerIndex, agentInstanceContext.AgentInstanceId); } bool removedStream = false; if (viewFactoryChain.Count > 1) { int countDataWindow = 0; foreach (ViewFactory viewFactory in viewFactoryChain) { if (viewFactory is DataWindowViewFactory) { countDataWindow++; } } removedStream = countDataWindow > 1; } return(new AgentInstanceViewFactoryChainContext(agentInstanceContext, removedStream, previousNodeGetter, priorViewUpdatedCollection)); }
// 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(); } } }
// Called based on schedule evaluation registered when a variable changes (new data is null). // Called when new data arrives. public void Expire(int numEventsInBatch) { if (numEventsInBatch == Window.Count || numEventsInBatch == -1) { var batchNewData = Window.ToArray(); if (ViewUpdatedCollection != null) { ViewUpdatedCollection.Update(batchNewData, LastBatch); } // post if (batchNewData != null || LastBatch != null) { Instrument.With( i => i.QViewIndicate(this, _dataWindowViewFactory.ViewName, batchNewData, LastBatch), i => i.AViewIndicate(), () => UpdateChildren(batchNewData, LastBatch)); } // clear Window.Clear(); LastBatch = batchNewData; if (AggregationService != null) { AggregationService.ClearResults(AgentInstanceContext); } OldestEvent = null; NewestEvent = null; } else { var batchNewData = Window.Take(numEventsInBatch).ToArray(); unchecked { for (int ii = 0; ii < batchNewData.Length; ii++) { Window.Remove(batchNewData[ii]); } } if (ViewUpdatedCollection != null) { ViewUpdatedCollection.Update(batchNewData, LastBatch); } // post if (batchNewData != null || LastBatch != null) { Instrument.With( i => i.QViewIndicate(this, _dataWindowViewFactory.ViewName, batchNewData, LastBatch), i => i.AViewIndicate(), () => UpdateChildren(batchNewData, LastBatch)); } // clear LastBatch = batchNewData; if (AggregationService != null) { AggregationService.ApplyLeave(batchNewData, null, AgentInstanceContext); } OldestEvent = Window.FirstOrDefault(); } }