コード例 #1
0
        public object Evaluate(
            EventBean[] eventsPerStream,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            IEnumerator<EventBean> events;
            int size;
            if (randomAccessGetter != null) {
                RandomAccessByIndex randomAccess = randomAccessGetter.Accessor;
                events = randomAccess.GetWindowEnumerator();
                size = (int) randomAccess.WindowCount;
            }
            else {
                EventBean evalEvent = eventsPerStream[streamNumber];
                RelativeAccessByEventNIndex relativeAccess = relativeAccessGetter.GetAccessor(evalEvent);
                if (relativeAccess == null) {
                    return null;
                }

                size = relativeAccess.WindowToEventCount;
                events = relativeAccess.WindowToEvent;
            }

            if (size <= 0) {
                return null;
            }

            EventBean originalEvent = eventsPerStream[streamNumber];
            Array result = Array.CreateInstance(componentType, size);

            for (int i = 0; i < size; i++) {
                events.MoveNext();
                eventsPerStream[streamNumber] = events.Current;
                result.SetValue(evalNode.Evaluate(eventsPerStream, true, exprEvaluatorContext), i);
            }

            eventsPerStream[streamNumber] = originalEvent;
            return result;
        }
コード例 #2
0
        public ICollection<object> EvaluateGetCollScalar(
            EventBean[] eventsPerStream,
            ExprEvaluatorContext context)
        {
            IEnumerator<EventBean> events;
            int size;
            if (randomAccessGetter != null) {
                RandomAccessByIndex randomAccess = randomAccessGetter.Accessor;
                events = randomAccess.GetWindowEnumerator();
                size = (int) randomAccess.WindowCount;
            }
            else {
                EventBean evalEvent = eventsPerStream[streamNumber];
                RelativeAccessByEventNIndex relativeAccess = relativeAccessGetter.GetAccessor(evalEvent);
                if (relativeAccess == null) {
                    return null;
                }

                size = relativeAccess.WindowToEventCount;
                events = relativeAccess.WindowToEvent;
            }

            if (size <= 0) {
                return Collections.GetEmptyList<object>();
            }

            EventBean originalEvent = eventsPerStream[streamNumber];
            Deque<object> deque = new ArrayDeque<object>(size);
            for (int i = 0; i < size; i++) {
                events.MoveNext();
                eventsPerStream[streamNumber] = events.Current;
                object evalResult = evalNode.Evaluate(eventsPerStream, true, context);
                deque.Add(evalResult);
            }

            eventsPerStream[streamNumber] = originalEvent;
            return deque;
        }