Exemplo n.º 1
0
        internal static void PopulateSelectJoinEventsHavingWithOrderBy(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, ICollection <MultiKey <EventBean> > events, ExprEvaluator havingNode, bool isNewData, bool isSynthesize, ICollection <EventBean> result, ICollection <Object> sortKeys, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (events == null)
            {
                return;
            }

            foreach (var key in events)
            {
                var eventsPerStream = key.Array;
                var evaluateParams  = new EvaluateParams(eventsPerStream, isNewData, exprEvaluatorContext);

                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().QHavingClauseJoin(eventsPerStream);
                }
                var passesHaving = havingNode.Evaluate(evaluateParams);
                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get().AHavingClauseJoin(passesHaving.AsBoxedBoolean());
                }
                if ((passesHaving == null) || (false.Equals(passesHaving)))
                {
                    continue;
                }

                var resultEvent = exprProcessor.Process(eventsPerStream, isNewData, isSynthesize, exprEvaluatorContext);
                if (resultEvent != null)
                {
                    result.Add(resultEvent);
                    sortKeys.Add(orderByProcessor.GetSortKey(eventsPerStream, isNewData, exprEvaluatorContext));
                }
            }
        }
Exemplo n.º 2
0
        public override IEnumerator <EventBean> GetEnumerator(Viewable parent)
        {
            if (_orderByProcessor != null)
            {
                // Pull all events, generate order keys
                var eventsPerStream = new EventBean[1];
                var events          = new List <EventBean>();
                var orderKeys       = new List <Object>();

                var parentEnumerator = parent.GetEnumerator();
                if (parentEnumerator.MoveNext() == false)
                {
                    return(CollectionUtil.NULL_EVENT_ITERATOR);
                }

                do
                {
                    var aParent = parentEnumerator.Current;
                    eventsPerStream[0] = aParent;
                    var orderKey = _orderByProcessor.GetSortKey(eventsPerStream, true, ExprEvaluatorContext);
                    var pair     = ProcessViewResultIterator(eventsPerStream);
                    var result   = pair.First;
                    if (result != null && result.Length != 0)
                    {
                        events.Add(result[0]);
                    }
                    orderKeys.Add(orderKey);
                } while (parentEnumerator.MoveNext());

                // sort
                var outgoingEvents = events.ToArray();
                var orderKeysArr   = orderKeys.ToArray();
                var orderedEvents  = _orderByProcessor.Sort(outgoingEvents, orderKeysArr, ExprEvaluatorContext);
                if (orderedEvents == null)
                {
                    return(EnumerationHelper <EventBean> .CreateEmptyEnumerator());
                }

                return(((IEnumerable <EventBean>)orderedEvents).GetEnumerator());
            }
            // Return an iterator that gives row-by-row a result

            var transform = new ResultSetProcessorSimpleTransform(this);

            return(parent.Select(transform.Transform).GetEnumerator());
        }
Exemplo n.º 3
0
        internal static void PopulateSelectJoinEventsNoHavingWithOrderBy(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, ICollection <MultiKey <EventBean> > events, bool isNewData, bool isSynthesize, ICollection <EventBean> result, ICollection <Object> optSortKeys, ExprEvaluatorContext exprEvaluatorContext)
        {
            var length = (events != null) ? events.Count : 0;

            if (length == 0)
            {
                return;
            }

            foreach (var key in events)
            {
                var eventsPerStream = key.Array;
                var resultEvent     = exprProcessor.Process(eventsPerStream, isNewData, isSynthesize, exprEvaluatorContext);
                if (resultEvent != null)
                {
                    result.Add(resultEvent);
                    optSortKeys.Add(orderByProcessor.GetSortKey(eventsPerStream, isNewData, exprEvaluatorContext));
                }
            }
        }
        public IEnumerator <EventBean> ObtainEnumerator(Viewable parent)
        {
            if (_orderByProcessor == null)
            {
                return(ResultSetAggregateAllEnumerator.New(parent, this, _exprEvaluatorContext));
            }

            // Pull all parent events, generate order keys
            var eventsPerStream = new EventBean[1];
            var outgoingEvents  = new List <EventBean>();
            var orderKeys       = new List <object>();

            var evaluateParams = new EvaluateParams(eventsPerStream, true, _exprEvaluatorContext);

            foreach (var candidate in parent)
            {
                eventsPerStream[0] = candidate;

                object pass = true;
                if (_prototype.OptionalHavingNode != null)
                {
                    pass = _prototype.OptionalHavingNode.Evaluate(evaluateParams);
                }
                if ((pass == null) || (false.Equals(pass)))
                {
                    continue;
                }

                outgoingEvents.Add(_selectExprProcessor.Process(eventsPerStream, true, true, _exprEvaluatorContext));

                var orderKey = _orderByProcessor.GetSortKey(eventsPerStream, true, _exprEvaluatorContext);
                orderKeys.Add(orderKey);
            }

            // sort
            var outgoingEventsArr = outgoingEvents.ToArray();
            var orderKeysArr      = orderKeys.ToArray();
            var orderedEvents     = _orderByProcessor.Sort(outgoingEventsArr, orderKeysArr, _exprEvaluatorContext) ?? EMPTY_EVENT_BEAN_LIST;

            return(orderedEvents.GetEnumerator());
        }
Exemplo n.º 5
0
        public IEnumerator <EventBean> ObtainIterator(Viewable parent)
        {
            if (_orderByProcessor == null)
            {
                return(ResultSetAggregateAllEnumerator.New(parent, this, _exprEvaluatorContext));
            }

            // Pull all parent events, generate order keys
            EventBean[]       eventsPerStream = new EventBean[1];
            IList <EventBean> outgoingEvents  = new List <EventBean>();
            IList <Object>    orderKeys       = new List <Object>();

            var evaluateParams = new EvaluateParams(eventsPerStream, true, _exprEvaluatorContext);

            foreach (EventBean candidate in parent)
            {
                eventsPerStream[0] = candidate;

                bool?pass = true;
                if (_prototype.OptionalHavingNode != null)
                {
                    pass = (bool?)_prototype.OptionalHavingNode.Evaluate(evaluateParams);
                }
                if ((pass == null) || (!pass.Value))
                {
                    continue;
                }

                outgoingEvents.Add(_selectExprProcessor.Process(eventsPerStream, true, true, _exprEvaluatorContext));

                Object orderKey = _orderByProcessor.GetSortKey(eventsPerStream, true, _exprEvaluatorContext);
                orderKeys.Add(orderKey);
            }

            // sort
            EventBean[] outgoingEventsArr = outgoingEvents.ToArray();
            Object[]    orderKeysArr      = orderKeys.ToArray();
            EventBean[] orderedEvents     = _orderByProcessor.Sort(outgoingEventsArr, orderKeysArr, _exprEvaluatorContext);

            return(((IEnumerable <EventBean>)orderedEvents).GetEnumerator());
        }
Exemplo n.º 6
0
        internal static void PopulateSelectEventsNoHavingWithOrderBy(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, EventBean[] events, bool isNewData, bool isSynthesize, ICollection <EventBean> result, ICollection <Object> sortKeys, ExprEvaluatorContext exprEvaluatorContext)
        {
            if (events == null)
            {
                return;
            }

            var eventsPerStream = new EventBean[1];

            foreach (var theEvent in events)
            {
                eventsPerStream[0] = theEvent;

                var resultEvent = exprProcessor.Process(eventsPerStream, isNewData, isSynthesize, exprEvaluatorContext);
                if (resultEvent != null)
                {
                    result.Add(resultEvent);
                    sortKeys.Add(orderByProcessor.GetSortKey(eventsPerStream, isNewData, exprEvaluatorContext));
                }
            }
        }