Example #1
0
        public object EvaluateEnumMethod(
            EventBean[] eventsLambda,
            ICollection<object> enumcoll,
            bool isNewData,
            ExprEvaluatorContext context)
        {
            if (enumcoll.IsEmpty()) {
                return enumcoll;
            }

            var evalEvent = new ObjectArrayEventBean(new object[1], _forge.evalEventType);
            eventsLambda[_forge.streamNumLambda] = evalEvent;
            var evalProps = evalEvent.Properties;
            var indexEvent = new ObjectArrayEventBean(new object[1], _forge.indexEventType);
            eventsLambda[_forge.streamNumLambda + 1] = indexEvent;
            var indexProps = indexEvent.Properties;

            if (enumcoll.Count == 1) {
                var item = enumcoll.First();
                evalProps[0] = item;
                indexProps[0] = 0;

                var pass = _innerExpression.Evaluate(eventsLambda, isNewData, context);
                if (pass == null || !(bool) pass) {
                    return Collections.GetEmptyList<object>();
                }

                return Collections.SingletonList(item);
            }

            var all = TakeWhileLastScalarToArray(enumcoll);
            var result = new ArrayDeque<object>();
            var index = 0;

            for (var i = all.Length - 1; i >= 0; i--) {
                evalProps[0] = all[i];
                indexProps[0] = index++;

                var pass = _innerExpression.Evaluate(eventsLambda, isNewData, context);
                if (pass == null || !(bool) pass) {
                    break;
                }

                result.AddFirst(all[i]);
            }

            return result;
        }
 public override void GetTraverseStatement(
     EventTypeIndexTraverse traverse,
     ICollection<int> statementIds,
     ArrayDeque<FilterItem> evaluatorStack)
 {
     evaluatorStack.AddFirst(new FilterItem(_advancedIndex.Expression, FilterOperator.ADVANCED_INDEX, this));
     PointRegionQuadTreeFilterIndexTraverse.Traverse(_quadTree, @object => {
         if (@object is FilterHandleSetNode filterHandleSetNode) {
             filterHandleSetNode.GetTraverseStatement(traverse, statementIds, evaluatorStack);
             return;
         }
         if (@object is FilterHandle filterHandle) {
             traverse.Invoke(evaluatorStack, filterHandle);
         }
     });
     evaluatorStack.RemoveFirst();
 }
Example #3
0
        public object EvaluateEnumMethod(
            EventBean[] eventsLambda,
            ICollection<object> enumcoll,
            bool isNewData,
            ExprEvaluatorContext context)
        {
            if (enumcoll.IsEmpty()) {
                return enumcoll;
            }

            var indexEvent = new ObjectArrayEventBean(new object[1], _forge.indexEventType);
            eventsLambda[_forge.streamNumLambda + 1] = indexEvent;
            var props = indexEvent.Properties;

            var beans = (ICollection<EventBean>) enumcoll;
            if (enumcoll.Count == 1) {
                var item = beans.First();
                props[0] = 0;
                eventsLambda[_forge.streamNumLambda] = item;

                var pass = _innerExpression.Evaluate(eventsLambda, isNewData, context);
                if (pass == null || false.Equals(pass)) {
                    return Collections.GetEmptyList<object>();
                }

                return Collections.SingletonList(item);
            }

            var all = EnumTakeWhileLastEventsForgeEval.TakeWhileLastEventBeanToArray(beans);
            var result = new ArrayDeque<object>();
            var index = 0;

            for (var i = all.Length - 1; i >= 0; i--) {
                props[0] = index++;
                eventsLambda[_forge.streamNumLambda] = all[i];

                var pass = _innerExpression.Evaluate(eventsLambda, isNewData, context);
                if (pass == null || false.Equals(pass)) {
                    break;
                }

                result.AddFirst(all[i]);
            }

            return result;
        }
Example #4
0
        public void TestAddFront()
        {
            var deque = new ArrayDeque <int>();

            Assert.That(deque.Count, Is.EqualTo(0));

            for (int ii = 1; ii <= 1000; ii++)
            {
                deque.AddFirst(ii);
                Assert.That(deque.Count, Is.EqualTo(ii));
                Assert.That(deque.First, Is.EqualTo(ii));
            }

            int index = 1000;

            foreach (var value in deque)
            {
                Assert.That(value, Is.EqualTo(index--));
            }
        }