public override IEnumerator <EventBean> GetEnumerator(Viewable parent)
        {
            // Return an iterator that gives row-by-row a result
            var transform = new ResultSetProcessorSimpleTransform(this);

            return(parent.Select(transform.Transform).GetEnumerator());
        }
Ejemplo 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());
        }