示例#1
0
        public void TestMixedEntryElement()
        {
            var list1 = new List <EventBean>();

            list1.Add(events.Get("a"));
            var keyA = new HashableMultiKey(new object[] { "keyA" });

            testMap.Put(keyA, list1);

            var list2 = new List <EventBean>();

            list2.Add(events.Get("c"));
            list2.Add(events.Get("d"));
            var keyB = new HashableMultiKey(new object[] { "keyB" });

            testMap.Put(keyB, list2);

            var list3 = new List <EventBean>();

            list3.Add(events.Get("e"));
            list3.Add(events.Get("f"));
            list3.Add(events.Get("g"));
            var keyC = new HashableMultiKey(new object[] { "keyC" });

            testMap.Put(keyC, list3);

            var enumerator = testMap.GetMultiLevelEnumerator();

            EPAssertionUtil.AssertEqualsExactOrder(
                new[] {
                events.Get("a"), events.Get("c"), events.Get("d"),
                events.Get("e"), events.Get("f"), events.Get("g")
            }, enumerator);
        }
示例#2
0
        private EventBean InplaceReplaceSortedEvents(
            object sortKey,
            object uniqueKeyToReplace,
            EventBean newData)
        {
            var existing = _sortedEvents.Get(sortKey);

            EventBean replaced = null;
            if (existing != null) {
                if (existing is IList<EventBean> existingList) {
                    for (int ii = 0; ii < existingList.Count; ii++) {
                        var eventForRank = existingList[ii];
                        if (GetUniqueKey(eventForRank).Equals(uniqueKeyToReplace)) {
                            existingList.RemoveAt(ii--);
                            replaced = eventForRank;
                            break;
                        }
                    }

                    existingList.Add(newData); // add to back as this is now the newest event
                }
                else {
                    replaced = (EventBean) existing;
                    _sortedEvents.Put(sortKey, newData);
                }
            }

            return replaced;
        }
示例#3
0
        private static ExprNode HandlePreviousFunctions(
            ExprNode defineItemExpression,
            IOrderedDictionary<int, IList<ExprPreviousMatchRecognizeNode>> previousNodes)
        {
            var previousVisitor = new ExprNodePreviousVisitorWParent();
            defineItemExpression.Accept(previousVisitor);

            if (previousVisitor.Previous == null) {
                return defineItemExpression;
            }

            foreach (var previousNodePair in previousVisitor.Previous) {
                var previousNode = previousNodePair.Second;
                var matchRecogPrevNode = new ExprPreviousMatchRecognizeNode();

                if (previousNodePair.Second.ChildNodes.Length == 1) {
                    matchRecogPrevNode.AddChildNode(previousNode.ChildNodes[0]);
                    matchRecogPrevNode.AddChildNode(new ExprConstantNodeImpl(1));
                }
                else if (previousNodePair.Second.ChildNodes.Length == 2) {
                    var first = previousNode.ChildNodes[0];
                    var second = previousNode.ChildNodes[1];
                    if (first is ExprConstantNode && !(second is ExprConstantNode)) {
                        matchRecogPrevNode.AddChildNode(second);
                        matchRecogPrevNode.AddChildNode(first);
                    }
                    else if (!(first is ExprConstantNode) && second is ExprConstantNode) {
                        matchRecogPrevNode.AddChildNode(first);
                        matchRecogPrevNode.AddChildNode(second);
                    }
                    else {
                        throw new ExprValidationException("PREV operator requires a constant index");
                    }
                }

                if (previousNodePair.First == null) {
                    defineItemExpression = matchRecogPrevNode;
                }
                else {
                    ExprNodeUtilityModify.ReplaceChildNode(
                        previousNodePair.First,
                        previousNodePair.Second,
                        matchRecogPrevNode);
                }

                // store in a list per index such that we can consolidate this into a single buffer
                var index = matchRecogPrevNode.ConstantIndexNumber;
                var callbackList = previousNodes.Get(index);
                if (callbackList == null) {
                    callbackList = new List<ExprPreviousMatchRecognizeNode>();
                    previousNodes.Put(index, callbackList);
                }

                callbackList.Add(matchRecogPrevNode);
            }

            return defineItemExpression;
        }
示例#4
0
 private void AddTrigger(long slot, ScheduleHandle handle, long triggerTime)
 {
     var handleSet = _timeHandleMap.Get(triggerTime);
     if (handleSet == null)
     {
         handleSet = new SortedDictionary<long, ScheduleHandle>();
         _timeHandleMap.Put(triggerTime, handleSet);
     }
     handleSet.Put(slot, handle);
     _handleSetMap.Put(handle, handleSet);
 }
        private static void MakeSendBean(
            RegressionEnvironment env,
            IOrderedDictionary <int, IList <SupportBean> > treemap,
            string theString,
            int intPrimitive)
        {
            var bean = new SupportBean(theString, intPrimitive);

            env.SendEventBean(bean);
            var existing = treemap.Get(intPrimitive);

            if (existing == null)
            {
                existing = new List <SupportBean>();
                treemap.Put(intPrimitive, existing);
            }

            existing.Add(bean);
            treemap.Put(bean.IntPrimitive, existing);
        }
示例#6
0
        public override void Put(
            object filterConstant,
            EventEvaluator matcher)
        {
            constantsMap.Put(filterConstant, matcher);

            // Update bounds
            double constant = filterConstant.AsDouble();
            if (lowerBounds == null || constant < lowerBounds) {
                lowerBounds = constant;
            }

            if (upperBounds == null || constant > upperBounds) {
                upperBounds = constant;
            }
        }
        public override void Put(
            object expressionValue,
            EventEvaluator matcher)
        {
            if (!(expressionValue is StringRange))
            {
                throw new ArgumentException("Supplied expressionValue must be of type DoubleRange");
            }

            var range = (StringRange)expressionValue;

            if (range.Max == null || range.Min == null)
            {
                RangesNullEndpoints = matcher;
                return;
            }

            Ranges.Put(range, matcher);
        }
示例#8
0
        public override void Add(
            EventBean theEvent,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            var key = GetIndexedValue(theEvent);

            key = Coerce(key);

            if (key == null) {
                nullKeyedValues.Add(theEvent);
                return;
            }

            var events = propertyIndex.Get(key);
            if (events == null) {
                events = new LinkedHashSet<EventBean>();
                propertyIndex.Put(key, events);
            }

            events.Add(theEvent);
        }
        public override void Put(
            object expressionValue,
            EventEvaluator matcher)
        {
            if (!(expressionValue is DoubleRange))
            {
                throw new ArgumentException("Supplied expressionValue must be of type DoubleRange");
            }

            var range = (DoubleRange)expressionValue;

            if (range.Max == null || range.Min == null)
            {
                RangesNullEndpoints = matcher;
                return;
            }

            if (Math.Abs(range.Max.Value - range.Min.Value) > LargestRangeValueDouble)
            {
                LargestRangeValueDouble = Math.Abs(range.Max.Value - range.Min.Value);
            }

            Ranges.Put(range, matcher);
        }
 public override void Put(
     object filterConstant,
     EventEvaluator matcher)
 {
     constantsMap.Put(filterConstant, matcher);
 }