コード例 #1
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            Instrument.With(
                i => i.QViewProcessIRStream(this, _timeWindowViewFactory.ViewName, newData, oldData),
                i => i.AViewProcessIRStream(),
                () =>
            {
                long timestamp = _agentInstanceContext.StatementContext.SchedulingService.Time;

                if (oldData != null)
                {
                    for (int i = 0; i < oldData.Length; i++)
                    {
                        _timeWindow.Remove(oldData[i]);
                    }
                }

                // we don't care about removed data from a prior view
                if ((newData != null) && (newData.Length > 0))
                {
                    // If we have an empty window about to be filled for the first time, schedule a callback
                    // for now plus timeDeltaComputation
                    if (_timeWindow.IsEmpty())
                    {
                        long current = _agentInstanceContext.StatementContext.SchedulingService.Time;
                        ScheduleCallback(_timeDeltaComputation.DeltaAdd(current));
                    }

                    // add data points to the timeWindow
                    for (int i = 0; i < newData.Length; i++)
                    {
                        _timeWindow.Add(timestamp, newData[i]);
                    }

                    if (_viewUpdatedCollection != null)
                    {
                        _viewUpdatedCollection.Update(newData, null);
                    }
                }

                // Update child views
                if (HasViews)
                {
                    Instrument.With(
                        i => i.QViewIndicate(this, _timeWindowViewFactory.ViewName, newData, oldData),
                        i => i.AViewIndicate(),
                        () => UpdateChildren(newData, oldData));
                }
            });
        }
コード例 #2
0
ファイル: TimeWindowView.cs プロジェクト: lanicon/nesper
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, timeWindowViewFactory);
            agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(timeWindowViewFactory, newData, oldData);
            var timestamp = agentInstanceContext.StatementContext.SchedulingService.Time;

            if (oldData != null) {
                for (var i = 0; i < oldData.Length; i++) {
                    timeWindow.Remove(oldData[i]);
                }
            }

            // we don't care about removed data from a prior view
            if (newData != null && newData.Length > 0) {
                // If we have an empty window about to be filled for the first time, schedule a callback
                // for now plus millisecondsBeforeExpiry
                if (timeWindow.IsEmpty()) {
                    var current = agentInstanceContext.StatementContext.SchedulingService.Time;
                    ScheduleCallback(timePeriodProvide.DeltaAdd(current, null, true, agentInstanceContext));
                }

                // add data points to the timeWindow
                for (var i = 0; i < newData.Length; i++) {
                    timeWindow.Add(timestamp, newData[i]);
                }

                ViewUpdatedCollection?.Update(newData, null);
            }

            // update child views
            agentInstanceContext.InstrumentationProvider.QViewIndicate(timeWindowViewFactory, newData, oldData);
            Child.Update(newData, oldData);
            agentInstanceContext.InstrumentationProvider.AViewIndicate();

            agentInstanceContext.InstrumentationProvider.AViewProcessIRStream();
        }
コード例 #3
0
 /// <summary>
 ///     Returns true to indicate the window is empty, or false if the view is not empty.
 /// </summary>
 /// <returns>true if empty</returns>
 public bool IsEmpty()
 {
     return(_timeWindow.IsEmpty());
 }