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());
        }
Пример #2
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());
 }
Пример #3
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));
        }
        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));
        }
        private UniformPair <EventBean[]> ProcessOutputLimitedJoinLast(IList <UniformPair <ISet <MultiKey <EventBean> > > > joinEventsSet, bool generateSynthetic)
        {
            EventBean lastOldEvent = null;
            EventBean lastNewEvent = null;

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

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

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

                EventBean[] selectOldEvents;
                if (_prototype.IsSelectRStream)
                {
                    if (_prototype.OptionalHavingNode == null)
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHaving(_selectExprProcessor, oldData, false, generateSynthetic, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_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.GetSelectJoinEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, _exprEvaluatorContext);
                }
                else
                {
                    selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_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));
        }
Пример #6
0
        public UniformPair <EventBean[]> ProcessOutputLimitedJoin(IList <UniformPair <ISet <MultiKey <EventBean> > > > joinEventsSet, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
        {
            if (outputLimitLimitType == OutputLimitLimitType.LAST)
            {
                EventBean lastOldEvent = null;
                EventBean lastNewEvent = null;

                foreach (UniformPair <ISet <MultiKey <EventBean> > > pair in joinEventsSet)
                {
                    ICollection <MultiKey <EventBean> > newData = pair.First;
                    ICollection <MultiKey <EventBean> > oldData = pair.Second;

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

                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (MultiKey <EventBean> eventsPerStream in newData)
                        {
                            _aggregationService.ApplyEnter(eventsPerStream.Array, null, _exprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (MultiKey <EventBean> eventsPerStream in oldData)
                        {
                            _aggregationService.ApplyLeave(eventsPerStream.Array, null, _exprEvaluatorContext);
                        }
                    }

                    EventBean[] selectOldEvents;
                    if (_prototype.IsSelectRStream)
                    {
                        if (_prototype.OptionalHavingNode == null)
                        {
                            selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsNoHaving(_selectExprProcessor, oldData, false, generateSynthetic, _exprEvaluatorContext);
                        }
                        else
                        {
                            selectOldEvents = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_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.GetSelectJoinEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectNewEvents = ResultSetProcessorUtil.GetSelectJoinEventsHaving(_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
            {
                IList <EventBean> newEvents = new List <EventBean>();
                IList <EventBean> oldEvents = null;
                if (_prototype.IsSelectRStream)
                {
                    oldEvents = new List <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 <ISet <MultiKey <EventBean> > > pair in joinEventsSet)
                {
                    ICollection <MultiKey <EventBean> > newData = pair.First;
                    ICollection <MultiKey <EventBean> > oldData = pair.Second;

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

                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (MultiKey <EventBean> row in newData)
                        {
                            _aggregationService.ApplyEnter(row.Array, null, _exprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (MultiKey <EventBean> row in oldData)
                        {
                            _aggregationService.ApplyLeave(row.Array, null, _exprEvaluatorContext);
                        }
                    }

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

                    // generate new events using select expressions
                    if (_prototype.OptionalHavingNode == null)
                    {
                        if (_orderByProcessor == null)
                        {
                            ResultSetProcessorUtil.PopulateSelectJoinEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, newEvents, _exprEvaluatorContext);
                        }
                        else
                        {
                            ResultSetProcessorUtil.PopulateSelectJoinEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, true, generateSynthetic, newEvents, newEventsSortKey, _exprEvaluatorContext);
                        }
                    }
                    else
                    {
                        if (_orderByProcessor == null)
                        {
                            ResultSetProcessorUtil.PopulateSelectJoinEventsHaving(_selectExprProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, newEvents, _exprEvaluatorContext);
                        }
                        else
                        {
                            ResultSetProcessorUtil.PopulateSelectJoinEventsHavingWithOrderBy(_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));
            }
        }