Esempio n. 1
0
        /// <summary>
        ///     The update method is called if the view does not participate in a join.
        /// </summary>
        /// <param name="newData">new events</param>
        /// <param name="oldData">old events</param>
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            var statementResultService = _agentInstanceContext.StatementResultService;
            var isGenerateSynthetic = statementResultService.IsMakeSynthetic;
            var isGenerateNatural = statementResultService.IsMakeNatural;

            var newOldEvents = _resultSetProcessor.ProcessViewResult(newData, oldData, isGenerateSynthetic);

            if (!isGenerateSynthetic && !isGenerateNatural) {
                if (AuditPath.isAuditEnabled) {
                    OutputStrategyUtil.IndicateEarlyReturn(_agentInstanceContext.StatementContext, newOldEvents);
                }

                return;
            }

            var forceOutput = false;
            if (newData == null &&
                oldData == null &&
                (newOldEvents == null || newOldEvents.First == null && newOldEvents.Second == null)) {
                forceOutput = true;
            }

            // Child view can be null in replay from named window
            if (child != null) {
                PostProcess(forceOutput, newOldEvents, child);
            }
        }
Esempio n. 2
0
        public EPPreparedQueryResult Execute(
            FAFQueryMethodSelect select,
            ContextPartitionSelector[] contextPartitionSelectors,
            FAFQueryMethodAssignerSetter assignerSetter,
            ContextManagementService contextManagementService)
        {
            var processor = select.Processors[0];

            var singleSelector = contextPartitionSelectors != null && contextPartitionSelectors.Length > 0
                ? contextPartitionSelectors[0]
                : null;
            var agentInstanceIds = AgentInstanceIds(processor, singleSelector, contextManagementService);

            IList<ContextPartitionResult> contextPartitionResults = new List<ContextPartitionResult>();
            foreach (var agentInstanceId in agentInstanceIds) {
                var processorInstance = processor.GetProcessorInstanceContextById(agentInstanceId);
                if (processorInstance != null) {
                    var coll = processorInstance.SnapshotBestEffort(select.QueryGraph, select.Annotations);
                    contextPartitionResults.Add(
                        new ContextPartitionResult(coll, processorInstance.AgentInstanceContext));
                }
            }

            // process context partitions
            var events = new ArrayDeque<EventBean[]>();
            ResultSetProcessor resultSetProcessor = null;
            foreach (var contextPartitionResult in contextPartitionResults) {
                if (resultSetProcessor == null) {
                    resultSetProcessor = ProcessorWithAssign(
                        select.ResultSetProcessorFactoryProvider,
                        contextPartitionResult.Context,
                        assignerSetter,
                        select.TableAccesses);
                }

                var snapshot = contextPartitionResult.Events;
                if (select.WhereClause != null) {
                    snapshot = Filtered(
                        snapshot,
                        select.WhereClause,
                        contextPartitionResult.Context);
                }

                var rows = snapshot.ToArray();
                resultSetProcessor.SetAgentInstanceContext(contextPartitionResult.Context);
                var results = resultSetProcessor.ProcessViewResult(rows, null, true);
                if (results != null && results.First != null && results.First.Length > 0) {
                    events.Add(results.First);
                }
            }

            var distinct = EventBeanUtility.GetDistinctByProp(
                EventBeanUtility.Flatten(events),
                select.EventBeanReaderDistinct);
            return new EPPreparedQueryResult(select.EventType, distinct);
        }
        public override void Update(
            EventBean[] newData,
            EventBean[] oldData)
        {
            var statementResultService = agentInstanceContext.StatementResultService;
            var isGenerateSynthetic = statementResultService.IsMakeSynthetic;
            var isGenerateNatural = statementResultService.IsMakeNatural;

            if (!isGenerateSynthetic && !isGenerateNatural) {
                return;
            }

            var result = resultSetProcessor.ProcessViewResult(newData, oldData, isGenerateSynthetic);
            child?.NewResult(result);
        }
Esempio n. 4
0
        /// <summary>
        /// The update method is called if the view does not participate in a join.
        /// </summary>
        /// <param name="newData">- new events</param>
        /// <param name="oldData">- old events</param>
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
            {
                Log.Debug(".update Received update, " +
                          "  newData.Length==" + ((newData == null) ? 0 : newData.Length) +
                          "  oldData.Length==" + ((oldData == null) ? 0 : oldData.Length));
            }

            bool isGenerateSynthetic = _parent.StatementResultService.IsMakeSynthetic;
            bool isGenerateNatural   = _parent.StatementResultService.IsMakeNatural;

            UniformPair <EventBean[]> newOldEvents = ResultSetProcessor.ProcessViewResult(newData, oldData, isGenerateSynthetic);

            if (!base.CheckAfterCondition(newOldEvents, _parent.StatementContext))
            {
                return;
            }

            if (_parent.IsDistinct && newOldEvents != null)
            {
                newOldEvents.First  = EventBeanUtility.GetDistinctByProp(newOldEvents.First, _parent.EventBeanReader);
                newOldEvents.Second = EventBeanUtility.GetDistinctByProp(newOldEvents.Second, _parent.EventBeanReader);
            }

            if ((!isGenerateSynthetic) && (!isGenerateNatural))
            {
                if (AuditPath.IsAuditEnabled)
                {
                    OutputStrategyUtil.IndicateEarlyReturn(_parent.StatementContext, newOldEvents);
                }
                return;
            }

            bool forceOutput = false;

            if ((newData == null) && (oldData == null) &&
                ((newOldEvents == null) || (newOldEvents.First == null && newOldEvents.Second == null)))
            {
                forceOutput = true;
            }

            // Child view can be null in replay from named window
            if (ChildView != null)
            {
                PostProcess(forceOutput, newOldEvents, ChildView);
            }
        }
Esempio n. 5
0
        protected internal static EPPreparedQueryResult ProcessedNonJoin(
            ResultSetProcessor resultSetProcessor,
            ICollection<EventBean> events,
            EventBeanReader distinctHandler)
        {
            var rows = events.ToArray();
            var results = resultSetProcessor.ProcessViewResult(rows, null, true);

            EventBean[] distinct;
            if (distinctHandler == null) {
                distinct = results.First;
            }
            else {
                distinct = EventBeanUtility.GetDistinctByProp(results.First, distinctHandler);
            }

            return new EPPreparedQueryResult(resultSetProcessor.ResultEventType, distinct);
        }
Esempio n. 6
0
        /// <summary>The Update method is called if the view does not participate in a join. </summary>
        /// <param name="newData">new events</param>
        /// <param name="oldData">old events</param>
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QOutputProcessNonBuffered(newData, oldData);
            }

            bool isGenerateSynthetic = _parent.StatementResultService.IsMakeSynthetic;
            bool isGenerateNatural   = _parent.StatementResultService.IsMakeNatural;

            UniformPair <EventBean[]> newOldEvents = ResultSetProcessor.ProcessViewResult(newData, oldData, isGenerateSynthetic);

            if ((!isGenerateSynthetic) && (!isGenerateNatural))
            {
                if (AuditPath.IsAuditEnabled)
                {
                    OutputStrategyUtil.IndicateEarlyReturn(_parent.StatementContext, newOldEvents);
                }
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AOutputProcessNonBuffered();
                }
                return;
            }

            bool forceOutput =
                (newData == null) &&
                (oldData == null) &&
                ((newOldEvents == null) || (newOldEvents.First == null && newOldEvents.Second == null));

            // Child view can be null in replay from named window
            if (ChildView != null)
            {
                PostProcess(forceOutput, newOldEvents, ChildView);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AOutputProcessNonBuffered();
            }
        }
 public EventBean Transform(EventBean theEvent)
 {
     newData[0] = theEvent;
     var pair = resultSetProcessor.ProcessViewResult(newData, null, true);
     return pair == null ? null : pair.First == null ? null : pair.First[0];
 }
Esempio n. 8
0
        public override void Update(EventBean[] newData, EventBean[] oldData)
        {
            UniformPair <EventBean[]> pair = ResultSetProcessor.ProcessViewResult(newData, oldData, false);

            _callback.OutputViaCallback(pair.First);
        }