Ejemplo n.º 1
0
        public void TestUpdateAll()
        {
            Assert.IsNull(ResultSetProcessorUtil.GetSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, (EventBean[])null, true, false, null));

            var testEvent1 = MakeEvent(10, 5, 6);
            var testEvent2 = MakeEvent(11, 6, 7);
            var newData    = new EventBean[] { testEvent1, testEvent2 };

            var testEvent3 = MakeEvent(20, 1, 2);
            var testEvent4 = MakeEvent(21, 3, 4);
            var oldData    = new EventBean[] { testEvent3, testEvent4 };

            var result    = _outputProcessorAll.ProcessViewResult(newData, oldData, false);
            var newEvents = result.First;
            var oldEvents = result.Second;

            Assert.AreEqual(2, newEvents.Length);
            Assert.AreEqual(10d, newEvents[0].Get("resultOne"));
            Assert.AreEqual(30, newEvents[0].Get("resultTwo"));

            Assert.AreEqual(11d, newEvents[1].Get("resultOne"));
            Assert.AreEqual(42, newEvents[1].Get("resultTwo"));

            Assert.AreEqual(2, oldEvents.Length);
            Assert.AreEqual(20d, oldEvents[0].Get("resultOne"));
            Assert.AreEqual(2, oldEvents[0].Get("resultTwo"));

            Assert.AreEqual(21d, oldEvents[1].Get("resultOne"));
            Assert.AreEqual(12, oldEvents[1].Get("resultTwo"));
        }
        public IEnumerator <EventBean> GetEnumerator(ISet <MultiKey <EventBean> > joinSet)
        {
            IList <EventBean> result;

            if (_prototype.OptionalHavingNode == null)
            {
                if (_orderByProcessor == null)
                {
                    result = ResultSetProcessorUtil.GetSelectJoinEventsNoHaving(_selectExprProcessor, joinSet, true, true, _exprEvaluatorContext);
                }
                else
                {
                    result = ResultSetProcessorUtil.GetSelectJoinEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, joinSet, true, true, _exprEvaluatorContext);
                }
            }
            else
            {
                if (_orderByProcessor == null)
                {
                    result = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_selectExprProcessor, joinSet, _prototype.OptionalHavingNode, true, true, _exprEvaluatorContext);
                }
                else
                {
                    result = ResultSetProcessorUtil.GetSelectJoinEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, joinSet, _prototype.OptionalHavingNode, true, true, _exprEvaluatorContext);
                }
            }
            return(result != null?result.GetEnumerator() : EnumerationHelper <EventBean> .Empty());
        }
Ejemplo n.º 3
0
        public void TestProcessAll()
        {
            Assert.IsNull(ResultSetProcessorUtil.GetSelectJoinEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, new HashSet <MultiKey <EventBean> >(), true, false, null));

            var testEvent1  = MakeEvent(10, 5, 6);
            var testEvent2  = MakeEvent(11, 6, 7);
            var newEventSet = MakeEventSet(testEvent1);

            newEventSet.Add(new MultiKey <EventBean>(new EventBean[] { testEvent2 }));

            var testEvent3  = MakeEvent(20, 1, 2);
            var testEvent4  = MakeEvent(21, 3, 4);
            var oldEventSet = MakeEventSet(testEvent3);

            oldEventSet.Add(new MultiKey <EventBean>(new EventBean[] { testEvent4 }));

            var result    = _outputProcessorAll.ProcessJoinResult(newEventSet, oldEventSet, false);
            var newEvents = result.First;
            var oldEvents = result.Second;

            Assert.AreEqual(2, newEvents.Length);
            Assert.AreEqual(10d, newEvents[0].Get("resultOne"));
            Assert.AreEqual(30, newEvents[0].Get("resultTwo"));

            Assert.AreEqual(11d, newEvents[1].Get("resultOne"));
            Assert.AreEqual(42, newEvents[1].Get("resultTwo"));

            Assert.AreEqual(2, oldEvents.Length);
            Assert.AreEqual(20d, oldEvents[0].Get("resultOne"));
            Assert.AreEqual(2, oldEvents[0].Get("resultTwo"));

            Assert.AreEqual(21d, oldEvents[1].Get("resultOne"));
            Assert.AreEqual(12, oldEvents[1].Get("resultTwo"));
        }
        public UniformPair <EventBean[]> ProcessViewResult(EventBean[] newData, EventBean[] oldData, bool isSynthesize)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QResultSetProcessUngroupedFullyAgg();
            }
            EventBean[] selectOldEvents = null;
            EventBean[] selectNewEvents;

            if (Prototype.IsSelectRStream)
            {
                selectOldEvents = GetSelectListEvents(false, isSynthesize, false);
            }

            EventBean[] eventsPerStream = new EventBean[1];
            ResultSetProcessorUtil.ApplyAggViewResult(AggregationService, ExprEvaluatorContext, newData, oldData, eventsPerStream);

            // generate new events using select expressions
            selectNewEvents = GetSelectListEvents(true, isSynthesize, false);

            if ((selectNewEvents == null) && (selectOldEvents == null))
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AResultSetProcessUngroupedFullyAgg(null, null);
                }
                return(null);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AResultSetProcessUngroupedFullyAgg(selectNewEvents, selectOldEvents);
            }
            return(new UniformPair <EventBean[]>(selectNewEvents, selectOldEvents));
        }
Ejemplo n.º 5
0
 public IEnumerator <EventBean> GetEnumerator(ISet <MultiKey <EventBean> > joinSet)
 {
     EventBean[] result;
     if (_prototype.OptionalHavingNode == null)
     {
         if (_orderByProcessor == null)
         {
             result = ResultSetProcessorUtil.GetSelectJoinEventsNoHaving(_selectExprProcessor, joinSet, true, true, _exprEvaluatorContext);
         }
         else
         {
             result = ResultSetProcessorUtil.GetSelectJoinEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, joinSet, true, true, _exprEvaluatorContext);
         }
     }
     else
     {
         if (_orderByProcessor == null)
         {
             result = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_selectExprProcessor, joinSet, _prototype.OptionalHavingNode, true, true, _exprEvaluatorContext);
         }
         else
         {
             result = ResultSetProcessorUtil.GetSelectJoinEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, joinSet, _prototype.OptionalHavingNode, true, true, _exprEvaluatorContext);
         }
     }
     if (result == null)
     {
         return(EnumerationHelper <EventBean> .CreateEmptyEnumerator());
     }
     return(((IEnumerable <EventBean>)result).GetEnumerator());
 }
Ejemplo n.º 6
0
        public void ProcessJoin(ISet <MultiKey <EventBean> > newEvents, ISet <MultiKey <EventBean> > oldEvents, bool isGenerateSynthetic)
        {
            if (_processor.Prototype.IsSelectRStream && _lastEventRStreamForOutputLast == null)
            {
                _lastEventRStreamForOutputLast = _processor.GetSelectListEvents(false, isGenerateSynthetic, true);
            }

            ResultSetProcessorUtil.ApplyAggJoinResult(_processor.AggregationService, _processor.ExprEvaluatorContext, newEvents, oldEvents);
        }
Ejemplo n.º 7
0
        public void ProcessView(EventBean[] newData, EventBean[] oldData, bool isGenerateSynthetic)
        {
            if (_processor.Prototype.IsSelectRStream && _lastEventRStreamForOutputLast == null)
            {
                _lastEventRStreamForOutputLast = _processor.GetSelectListEvents(false, isGenerateSynthetic, false);
            }

            EventBean[] eventsPerStream = new EventBean[1];
            ResultSetProcessorUtil.ApplyAggViewResult(_processor.AggregationService, _processor.ExprEvaluatorContext, newData, oldData, eventsPerStream);
        }
        public IEnumerator <EventBean> GetEnumerator(Viewable parent)
        {
            if (!_prototype.IsHistoricalOnly)
            {
                return(ObtainEnumerator(parent));
            }

            ResultSetProcessorUtil.ClearAndAggregateUngrouped(_exprEvaluatorContext, _aggregationService, parent);
            ArrayDeque <EventBean> deque = ResultSetProcessorUtil.EnumeratorToDeque(ObtainEnumerator(parent));

            _aggregationService.ClearResults(_exprEvaluatorContext);
            return(deque.GetEnumerator());
        }
        public void ProcessJoin(ISet <MultiKey <EventBean> > newEvents, ISet <MultiKey <EventBean> > oldEvents, bool isGenerateSynthetic)
        {
            if (processor.Prototype.IsSelectRStream)
            {
                EventBean[] eventsX = processor.GetSelectListEvents(false, isGenerateSynthetic, true);
                EventBeanUtility.AddToCollection(eventsX, eventsOld);
            }

            ResultSetProcessorUtil.ApplyAggJoinResult(processor.AggregationService, processor._exprEvaluatorContext, newEvents, oldEvents);

            EventBean[] events = processor.GetSelectListEvents(true, isGenerateSynthetic, true);
            EventBeanUtility.AddToCollection(events, eventsNew);
        }
Ejemplo n.º 10
0
        public IEnumerator <EventBean> GetEnumerator(Viewable parent)
        {
            if (!Prototype.IsHistoricalOnly)
            {
                return(ObtainEnumerator());
            }

            ResultSetProcessorUtil.ClearAndAggregateUngrouped(ExprEvaluatorContext, AggregationService, parent);

            var enumerator = ObtainEnumerator();

            AggregationService.ClearResults(ExprEvaluatorContext);
            return(enumerator);
        }
        public void ProcessView(EventBean[] newData, EventBean[] oldData, bool isGenerateSynthetic)
        {
            if (processor.Prototype.IsSelectRStream)
            {
                EventBean[] eventsX = processor.GetSelectListEvents(false, isGenerateSynthetic, false);
                EventBeanUtility.AddToCollection(eventsX, eventsOld);
            }

            EventBean[] eventsPerStream = new EventBean[1];
            ResultSetProcessorUtil.ApplyAggViewResult(processor.AggregationService, processor._exprEvaluatorContext, newData, oldData, eventsPerStream);

            EventBean[] events = processor.GetSelectListEvents(true, isGenerateSynthetic, false);
            EventBeanUtility.AddToCollection(events, eventsNew);
        }
Ejemplo n.º 12
0
        /// <summary>Process view results for the iterator. </summary>
        /// <param name="newData">new events</param>
        /// <returns>pair of insert and remove stream</returns>
        public UniformPair <EventBean[]> ProcessViewResultIterator(EventBean[] newData)
        {
            EventBean[] selectNewEvents;
            if (Prototype.OptionalHavingExpr == null)
            {
                // ignore _orderByProcessor
                selectNewEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, newData, true, true, ExprEvaluatorContext);
            }
            else
            {
                // ignore _orderByProcessor
                selectNewEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, newData, Prototype.OptionalHavingExpr, true, true, ExprEvaluatorContext);
            }

            return(new UniformPair <EventBean[]>(selectNewEvents, null));
        }
Ejemplo n.º 13
0
        public UniformPair <EventBean[]> ProcessJoinResult(ISet <MultiKey <EventBean> > newEvents, ISet <MultiKey <EventBean> > oldEvents, bool isSynthesize)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QResultSetProcessUngroupedFullyAgg();
            }
            EventBean[] selectOldEvents = null;
            EventBean[] selectNewEvents;

            if (_prototype.IsUnidirectional)
            {
                Clear();
            }

            if (_prototype.IsSelectRStream)
            {
                selectOldEvents = GetSelectListEvents(false, isSynthesize, true);
            }

            ResultSetProcessorUtil.ApplyAggJoinResult(_aggregationService, _exprEvaluatorContext, newEvents, oldEvents);

            selectNewEvents = GetSelectListEvents(true, isSynthesize, true);

            if ((selectNewEvents == null) && (selectOldEvents == null))
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AResultSetProcessUngroupedFullyAgg(null, null);
                }
                return(null);
            }
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AResultSetProcessUngroupedFullyAgg(selectNewEvents, selectOldEvents);
            }
            return(new UniformPair <EventBean[]>(selectNewEvents, selectOldEvents));
        }
Ejemplo n.º 14
0
 public void ApplyJoinResult(ISet <MultiKey <EventBean> > newEvents, ISet <MultiKey <EventBean> > oldEvents)
 {
     ResultSetProcessorUtil.ApplyAggJoinResult(_aggregationService, _exprEvaluatorContext, newEvents, oldEvents);
 }
Ejemplo n.º 15
0
        public void ApplyViewResult(EventBean[] newData, EventBean[] oldData)
        {
            var events = new EventBean[1];

            ResultSetProcessorUtil.ApplyAggViewResult(_aggregationService, _exprEvaluatorContext, newData, oldData, events);
        }
Ejemplo n.º 16
0
        public UniformPair <EventBean[]> ProcessViewResult(EventBean[] newData, EventBean[] oldData, bool isSynthesize)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QResultSetProcessUngroupedNonfullyAgg();
            }
            EventBean[] selectOldEvents = null;
            EventBean[] selectNewEvents;

            var eventsPerStream = new EventBean[1];

            ResultSetProcessorUtil.ApplyAggViewResult(_aggregationService, _exprEvaluatorContext, newData, oldData, eventsPerStream);

            // generate new events using select expressions
            if (_prototype.OptionalHavingNode == null)
            {
                if (_prototype.IsSelectRStream)
                {
                    if (_orderByProcessor == null)
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, oldData, false, isSynthesize, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldData, false, isSynthesize, _exprEvaluatorContext);
                    }
                }

                if (_orderByProcessor == null)
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, newData, true, isSynthesize, _exprEvaluatorContext);
                }
                else
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, true, isSynthesize, _exprEvaluatorContext);
                }
            }
            else
            {
                if (_prototype.IsSelectRStream)
                {
                    if (_orderByProcessor == null)
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, oldData, _prototype.OptionalHavingNode, false, isSynthesize, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldData, _prototype.OptionalHavingNode, false, isSynthesize, _exprEvaluatorContext);
                    }
                }

                if (_orderByProcessor == null)
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, newData, _prototype.OptionalHavingNode, true, isSynthesize, _exprEvaluatorContext);
                }
                else
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, _prototype.OptionalHavingNode, true, isSynthesize, _exprEvaluatorContext);
                }
            }

            if ((selectNewEvents == null) && (selectOldEvents == null))
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AResultSetProcessUngroupedNonfullyAgg(null, null);
                }
                return(null);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AResultSetProcessUngroupedNonfullyAgg(selectNewEvents, selectOldEvents);
            }
            return(new UniformPair <EventBean[]>(selectNewEvents, selectOldEvents));
        }
Ejemplo n.º 17
0
        private UniformPair <EventBean[]> ProcessOutputLimitedViewDefault(IList <UniformPair <EventBean[]> > viewEventsList, bool generateSynthetic)
        {
            IList <EventBean> newEvents = new List <EventBean>();
            IList <EventBean> oldEvents = null;

            if (_prototype.IsSelectRStream)
            {
                oldEvents = new List <EventBean>();
            }
            IList <object> newEventsSortKey = null;
            IList <object> oldEventsSortKey = null;

            if (_orderByProcessor != null)
            {
                newEventsSortKey = new List <object>();
                if (_prototype.IsSelectRStream)
                {
                    oldEventsSortKey = new List <object>();
                }
            }

            foreach (var pair in viewEventsList)
            {
                var newData = pair.First;
                var oldData = pair.Second;

                var eventsPerStream = new EventBean[1];
                if (newData != null)
                {
                    // apply new data to aggregates
                    foreach (var aNewData in newData)
                    {
                        eventsPerStream[0] = aNewData;
                        _aggregationService.ApplyEnter(eventsPerStream, null, _exprEvaluatorContext);
                    }
                }
                if (oldData != null)
                {
                    // apply old data to aggregates
                    foreach (var anOldData in oldData)
                    {
                        eventsPerStream[0] = anOldData;
                        _aggregationService.ApplyLeave(eventsPerStream, null, _exprEvaluatorContext);
                    }
                }

                // generate old events using select expressions
                if (_prototype.IsSelectRStream)
                {
                    if (_prototype.OptionalHavingNode == null)
                    {
                        if (_orderByProcessor == null)
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsNoHaving(_selectExprProcessor, oldData, false, generateSynthetic, oldEvents, _exprEvaluatorContext);
                        }
                        else
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldData, false, generateSynthetic, oldEvents, oldEventsSortKey, _exprEvaluatorContext);
                        }
                    }
                    // generate old events using having then select
                    else
                    {
                        if (_orderByProcessor == null)
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsHaving(_selectExprProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, oldEvents, _exprEvaluatorContext);
                        }
                        else
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, oldEvents, oldEventsSortKey, _exprEvaluatorContext);
                        }
                    }
                }

                // generate new events using select expressions
                if (_prototype.OptionalHavingNode == null)
                {
                    if (_orderByProcessor == null)
                    {
                        ResultSetProcessorUtil.PopulateSelectEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, newEvents, _exprEvaluatorContext);
                    }
                    else
                    {
                        ResultSetProcessorUtil.PopulateSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, true, generateSynthetic, newEvents, newEventsSortKey, _exprEvaluatorContext);
                    }
                }
                else
                {
                    if (_orderByProcessor == null)
                    {
                        ResultSetProcessorUtil.PopulateSelectEventsHaving(_selectExprProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, newEvents, _exprEvaluatorContext);
                    }
                    else
                    {
                        ResultSetProcessorUtil.PopulateSelectEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, newEvents, newEventsSortKey, _exprEvaluatorContext);
                    }
                }
            }

            var newEventsArr = (newEvents.IsEmpty()) ? null : newEvents.ToArray();

            EventBean[] oldEventsArr = null;
            if (_prototype.IsSelectRStream)
            {
                oldEventsArr = (oldEvents.IsEmpty()) ? null : oldEvents.ToArray();
            }
            if (_orderByProcessor != null)
            {
                var sortKeysNew = (newEventsSortKey.IsEmpty()) ? null : newEventsSortKey.ToArray();
                newEventsArr = _orderByProcessor.Sort(newEventsArr, sortKeysNew, _exprEvaluatorContext);

                if (_prototype.IsSelectRStream)
                {
                    var sortKeysOld = (oldEventsSortKey.IsEmpty()) ? null : oldEventsSortKey.ToArray();
                    oldEventsArr = _orderByProcessor.Sort(oldEventsArr, sortKeysOld, _exprEvaluatorContext);
                }
            }

            if ((newEventsArr == null) && (oldEventsArr == null))
            {
                return(null);
            }
            return(new UniformPair <EventBean[]>(newEventsArr, oldEventsArr));
        }
Ejemplo n.º 18
0
        private UniformPair <EventBean[]> ProcessOutputLimitedViewLast(IList <UniformPair <EventBean[]> > viewEventsList, bool generateSynthetic)
        {
            EventBean lastOldEvent    = null;
            EventBean lastNewEvent    = null;
            var       eventsPerStream = new EventBean[1];

            foreach (var pair in viewEventsList)
            {
                var newData = pair.First;
                var oldData = pair.Second;

                if (newData != null)
                {
                    // apply new data to aggregates
                    foreach (var aNewData in newData)
                    {
                        eventsPerStream[0] = aNewData;
                        _aggregationService.ApplyEnter(eventsPerStream, null, _exprEvaluatorContext);
                    }
                }
                if (oldData != null)
                {
                    // apply old data to aggregates
                    foreach (var anOldData in oldData)
                    {
                        eventsPerStream[0] = anOldData;
                        _aggregationService.ApplyLeave(eventsPerStream, null, _exprEvaluatorContext);
                    }
                }

                EventBean[] selectOldEvents;
                if (_prototype.IsSelectRStream)
                {
                    if (_prototype.OptionalHavingNode == null)
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, oldData, false, generateSynthetic, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, _exprEvaluatorContext);
                    }
                    if ((selectOldEvents != null) && (selectOldEvents.Length > 0))
                    {
                        lastOldEvent = selectOldEvents[selectOldEvents.Length - 1];
                    }
                }

                // generate new events using select expressions
                EventBean[] selectNewEvents;
                if (_prototype.OptionalHavingNode == null)
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, _exprEvaluatorContext);
                }
                else
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, _exprEvaluatorContext);
                }
                if ((selectNewEvents != null) && (selectNewEvents.Length > 0))
                {
                    lastNewEvent = selectNewEvents[selectNewEvents.Length - 1];
                }
            }

            var lastNew = (lastNewEvent != null) ? new EventBean[] { lastNewEvent } : null;
            var lastOld = (lastOldEvent != null) ? new EventBean[] { lastOldEvent } : null;

            if ((lastNew == null) && (lastOld == null))
            {
                return(null);
            }
            return(new UniformPair <EventBean[]>(lastNew, lastOld));
        }
Ejemplo n.º 19
0
        public UniformPair <EventBean[]> ProcessJoinResult(ISet <MultiKey <EventBean> > newEvents, ISet <MultiKey <EventBean> > oldEvents, bool isSynthesize)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QResultSetProcessUngroupedNonfullyAgg();
            }
            EventBean[] selectOldEvents = null;
            EventBean[] selectNewEvents;

            if (_prototype.IsUnidirectional)
            {
                Clear();
            }

            ResultSetProcessorUtil.ApplyAggJoinResult(_aggregationService, _exprEvaluatorContext, newEvents, oldEvents);

            if (_prototype.OptionalHavingNode == null)
            {
                if (_prototype.IsSelectRStream)
                {
                    if (_orderByProcessor == null)
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHaving(_selectExprProcessor, oldEvents, false, isSynthesize, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldEvents, false, isSynthesize, _exprEvaluatorContext);
                    }
                }

                if (_orderByProcessor == null)
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHaving(_selectExprProcessor, newEvents, true, isSynthesize, _exprEvaluatorContext);
                }
                else
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newEvents, true, isSynthesize, _exprEvaluatorContext);
                }
            }
            else
            {
                if (_prototype.IsSelectRStream)
                {
                    if (_orderByProcessor == null)
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_selectExprProcessor, oldEvents, _prototype.OptionalHavingNode, false, isSynthesize, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldEvents, _prototype.OptionalHavingNode, false, isSynthesize, _exprEvaluatorContext);
                    }
                }

                if (_orderByProcessor == null)
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_selectExprProcessor, newEvents, _prototype.OptionalHavingNode, true, isSynthesize, _exprEvaluatorContext);
                }
                else
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newEvents, _prototype.OptionalHavingNode, true, isSynthesize, _exprEvaluatorContext);
                }
            }

            if ((selectNewEvents == null) && (selectOldEvents == null))
            {
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AResultSetProcessUngroupedNonfullyAgg(null, null);
                }
                return(null);
            }
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AResultSetProcessUngroupedNonfullyAgg(selectNewEvents, selectOldEvents);
            }
            return(new UniformPair <EventBean[]>(selectNewEvents, selectOldEvents));
        }
Ejemplo n.º 20
0
        public override UniformPair <EventBean[]> ProcessJoinResult(ISet <MultiKey <EventBean> > newEvents, ISet <MultiKey <EventBean> > oldEvents, bool isSynthesize)
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().QResultSetProcessSimple();
            }

            EventBean[] selectOldEvents = null;
            EventBean[] selectNewEvents;

            if (Prototype.OptionalHavingExpr == null)
            {
                if (Prototype.IsSelectRStream)
                {
                    if (_orderByProcessor == null)
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHaving(_selectExprProcessor, oldEvents, false, isSynthesize, ExprEvaluatorContext);
                    }
                    else
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldEvents, false, isSynthesize, ExprEvaluatorContext);
                    }
                }

                if (_orderByProcessor == null)
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHaving(_selectExprProcessor, newEvents, true, isSynthesize, ExprEvaluatorContext);
                }
                else
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newEvents, true, isSynthesize, ExprEvaluatorContext);
                }
            }
            else
            {
                if (Prototype.IsSelectRStream)
                {
                    if (_orderByProcessor == null)
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_selectExprProcessor, oldEvents, Prototype.OptionalHavingExpr, false, isSynthesize, ExprEvaluatorContext);
                    }
                    else
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldEvents, Prototype.OptionalHavingExpr, false, isSynthesize, ExprEvaluatorContext);
                    }
                }

                if (_orderByProcessor == null)
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_selectExprProcessor, newEvents, Prototype.OptionalHavingExpr, true, isSynthesize, ExprEvaluatorContext);
                }
                else
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newEvents, Prototype.OptionalHavingExpr, true, isSynthesize, ExprEvaluatorContext);
                }
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.Get().AResultSetProcessSimple(selectNewEvents, selectOldEvents);
            }
            return(new UniformPair <EventBean[]>(selectNewEvents, selectOldEvents));
        }
Ejemplo n.º 21
0
        public UniformPair <EventBean[]> ProcessOutputLimitedView(IList <UniformPair <EventBean[]> > viewEventsList, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
        {
            if (outputLimitLimitType == OutputLimitLimitType.LAST)
            {
                EventBean   lastOldEvent    = null;
                EventBean   lastNewEvent    = null;
                EventBean[] eventsPerStream = new EventBean[1];

                foreach (UniformPair <EventBean[]> pair in viewEventsList)
                {
                    EventBean[] newData = pair.First;
                    EventBean[] oldData = pair.Second;

                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (EventBean aNewData in newData)
                        {
                            eventsPerStream[0] = aNewData;
                            _aggregationService.ApplyEnter(eventsPerStream, null, _exprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (EventBean anOldData in oldData)
                        {
                            eventsPerStream[0] = anOldData;
                            _aggregationService.ApplyLeave(eventsPerStream, null, _exprEvaluatorContext);
                        }
                    }

                    EventBean[] selectOldEvents;
                    if (_prototype.IsSelectRStream)
                    {
                        if (_prototype.OptionalHavingNode == null)
                        {
                            selectOldEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, oldData, false, generateSynthetic, _exprEvaluatorContext);
                        }
                        else
                        {
                            selectOldEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, _exprEvaluatorContext);
                        }
                        if ((selectOldEvents != null) && (selectOldEvents.Length > 0))
                        {
                            lastOldEvent = selectOldEvents[selectOldEvents.Length - 1];
                        }
                    }

                    // generate new events using select expressions
                    EventBean[] selectNewEvents;
                    if (_prototype.OptionalHavingNode == null)
                    {
                        selectNewEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectNewEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, _exprEvaluatorContext);
                    }
                    if ((selectNewEvents != null) && (selectNewEvents.Length > 0))
                    {
                        lastNewEvent = selectNewEvents[selectNewEvents.Length - 1];
                    }
                }

                EventBean[] lastNew = (lastNewEvent != null) ? new EventBean[] { lastNewEvent } : null;
                EventBean[] lastOld = (lastOldEvent != null) ? new EventBean[] { lastOldEvent } : null;

                if ((lastNew == null) && (lastOld == null))
                {
                    return(null);
                }
                return(new UniformPair <EventBean[]>(lastNew, lastOld));
            }
            else
            {
                ICollection <EventBean> newEvents = new List <EventBean>();
                ICollection <EventBean> oldEvents = null;
                if (_prototype.IsSelectRStream)
                {
                    oldEvents = new LinkedList <EventBean>();
                }
                ICollection <Object> newEventsSortKey = null;
                ICollection <Object> oldEventsSortKey = null;
                if (_orderByProcessor != null)
                {
                    newEventsSortKey = new LinkedList <Object>();
                    if (_prototype.IsSelectRStream)
                    {
                        oldEventsSortKey = new LinkedList <Object>();
                    }
                }

                foreach (UniformPair <EventBean[]> pair in viewEventsList)
                {
                    EventBean[] newData = pair.First;
                    EventBean[] oldData = pair.Second;

                    EventBean[] eventsPerStream = new EventBean[1];
                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (EventBean aNewData in newData)
                        {
                            eventsPerStream[0] = aNewData;
                            _aggregationService.ApplyEnter(eventsPerStream, null, _exprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (EventBean anOldData in oldData)
                        {
                            eventsPerStream[0] = anOldData;
                            _aggregationService.ApplyLeave(eventsPerStream, null, _exprEvaluatorContext);
                        }
                    }

                    // generate old events using select expressions
                    if (_prototype.IsSelectRStream)
                    {
                        if (_prototype.OptionalHavingNode == null)
                        {
                            if (_orderByProcessor == null)
                            {
                                ResultSetProcessorUtil.PopulateSelectEventsNoHaving(_selectExprProcessor, oldData, false, generateSynthetic, oldEvents, _exprEvaluatorContext);
                            }
                            else
                            {
                                ResultSetProcessorUtil.PopulateSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldData, false, generateSynthetic, oldEvents, oldEventsSortKey, _exprEvaluatorContext);
                            }
                        }
                        // generate old events using having then select
                        else
                        {
                            if (_orderByProcessor == null)
                            {
                                ResultSetProcessorUtil.PopulateSelectEventsHaving(_selectExprProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, oldEvents, _exprEvaluatorContext);
                            }
                            else
                            {
                                ResultSetProcessorUtil.PopulateSelectEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, oldEvents, oldEventsSortKey, _exprEvaluatorContext);
                            }
                        }
                    }

                    // generate new events using select expressions
                    if (_prototype.OptionalHavingNode == null)
                    {
                        if (_orderByProcessor == null)
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, newEvents, _exprEvaluatorContext);
                        }
                        else
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, true, generateSynthetic, newEvents, newEventsSortKey, _exprEvaluatorContext);
                        }
                    }
                    else
                    {
                        if (_orderByProcessor == null)
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsHaving(_selectExprProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, newEvents, _exprEvaluatorContext);
                        }
                        else
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, newEvents, newEventsSortKey, _exprEvaluatorContext);
                        }
                    }
                }

                EventBean[] newEventsArr = (newEvents.IsEmpty()) ? null : newEvents.ToArray();
                EventBean[] oldEventsArr = null;
                if (_prototype.IsSelectRStream)
                {
                    oldEventsArr = (oldEvents.IsEmpty()) ? null : oldEvents.ToArray();
                }
                if (_orderByProcessor != null)
                {
                    Object[] sortKeysNew = (newEventsSortKey.IsEmpty()) ? null : newEventsSortKey.ToArray();
                    newEventsArr = _orderByProcessor.Sort(newEventsArr, sortKeysNew, _exprEvaluatorContext);

                    if (_prototype.IsSelectRStream)
                    {
                        Object[] sortKeysOld = (oldEventsSortKey.IsEmpty()) ? null : oldEventsSortKey.ToArray();
                        oldEventsArr = _orderByProcessor.Sort(oldEventsArr, sortKeysOld, _exprEvaluatorContext);
                    }
                }

                if ((newEventsArr == null) && (oldEventsArr == null))
                {
                    return(null);
                }
                return(new UniformPair <EventBean[]>(newEventsArr, oldEventsArr));
            }
        }