Пример #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);

            IEnumerator <EventBean> 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
        public void TestInvalid()
        {
            comparator = new ComparatorHashableMultiKey(new bool[] { false, false });

            firstValues  = new HashableMultiKey(new object[] { 3d });
            secondValues = new HashableMultiKey(new object[] { 3d, 4L });
            try
            {
                comparator.Compare(firstValues, secondValues);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                // Expected
            }

            firstValues  = new HashableMultiKey(new object[] { 3d });
            secondValues = new HashableMultiKey(new object[] { 3d });
            try
            {
                comparator.Compare(firstValues, secondValues);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                // Expected
            }
        }
Пример #3
0
        public void TestCompareTwoProperties()
        {
            comparator = new ComparatorHashableMultiKey(new bool[] { false, false });

            firstValues  = new HashableMultiKey(new object[] { 3d, 3L });
            secondValues = new HashableMultiKey(new object[] { 3d, 4L });
            Assert.IsTrue(comparator.Compare(firstValues, secondValues) < 0);

            comparator = new ComparatorHashableMultiKey(new bool[] { false, true });

            Assert.IsTrue(comparator.Compare(firstValues, secondValues) > 0);
            Assert.IsTrue(comparator.Compare(firstValues, firstValues) == 0);
        }
Пример #4
0
        public void TestCompareSingleProperty()
        {
            comparator = new ComparatorHashableMultiKey(new bool[] { false });

            firstValues  = new HashableMultiKey(new object[] { 3d });
            secondValues = new HashableMultiKey(new object[] { 4d });
            Assert.IsTrue(comparator.Compare(firstValues, secondValues) < 0);

            comparator = new ComparatorHashableMultiKey(new bool[] { true });

            Assert.IsTrue(comparator.Compare(firstValues, secondValues) > 0);
            Assert.IsTrue(comparator.Compare(firstValues, firstValues) == 0);
        }
Пример #5
0
        public void TestOneElement()
        {
            var list = new List <EventBean>();

            list.Add(events.Get("a"));
            var key = new HashableMultiKey(new object[] { "akey" });

            testMap.Put(key, list);

            IEnumerator <EventBean> enumerator = testMap.GetMultiLevelEnumerator();

            EPAssertionUtil.AssertEqualsExactOrder(new[] { events.Get("a") }, enumerator);
        }
Пример #6
0
        public void TestIndex()
        {
            FilterParamIndexNotIn index = new FilterParamIndexNotIn(MakeLookupable("LongBoxed"), new SlimReaderWriterLock());

            Assert.AreEqual(FilterOperator.NOT_IN_LIST_OF_VALUES, index.FilterOperator);

            index.Put(new HashableMultiKey(new object[] { 2L, 5L }), testEvaluators[0]);
            index.Put(new HashableMultiKey(new object[] { 3L, 4L, 5L }), testEvaluators[1]);
            index.Put(new HashableMultiKey(new object[] { 1L, 4L, 5L }), testEvaluators[2]);
            index.Put(new HashableMultiKey(new object[] { 2L, 5L }), testEvaluators[3]);

            Verify(index, 0L, new bool[] { true, true, true, true });
            Verify(index, 1L, new bool[] { true, true, false, true });
            Verify(index, 2L, new bool[] { false, true, true, false });
            Verify(index, 3L, new bool[] { true, false, true, true });
            Verify(index, 4L, new bool[] { true, false, false, true });
            Verify(index, 5L, new bool[] { false, false, false, false });
            Verify(index, 6L, new bool[] { true, true, true, true });

            HashableMultiKey inList = new HashableMultiKey(new object[] { 3L, 4L, 5L });

            Assert.AreEqual(testEvaluators[1], index.Get(inList));
            Assert.IsTrue(index.ReadWriteLock != null);
            index.Remove(inList);
            index.Remove(inList);
            Assert.AreEqual(null, index.Get(inList));

            // now that {3,4,5} is removed, verify results again
            Verify(index, 0L, new bool[] { true, false, true, true });
            Verify(index, 1L, new bool[] { true, false, false, true });
            Verify(index, 2L, new bool[] { false, false, true, false });
            Verify(index, 3L, new bool[] { true, false, true, true });
            Verify(index, 4L, new bool[] { true, false, false, true });
            Verify(index, 5L, new bool[] { false, false, false, false });
            Verify(index, 6L, new bool[] { true, false, true, true });

            try
            {
                index.Put("a", testEvaluators[0]);
                Assert.IsTrue(false);
            }
            catch (Exception)
            {
                // Expected
            }
        }
Пример #7
0
        public static ExprNode TryResolveAsAggregation(
            ImportServiceCompileTime importService,
            bool distinct,
            string functionName,
            LazyAllocatedMap<HashableMultiKey, AggregationMultiFunctionForge> plugInAggregations,
            ClassProvidedExtension classProvidedExtension)
        {
            try {
                AggregationFunctionForge aggregationFactory = importService.ResolveAggregationFunction(functionName, classProvidedExtension);
                return new ExprPlugInAggNode(distinct, aggregationFactory, functionName);
            }
            catch (ImportUndefinedException) {
                // Not an aggregation function
            }
            catch (ImportException e) {
                throw new ValidationException("Error resolving aggregation: " + e.Message, e);
            }

            // try plug-in aggregation multi-function
            Pair<ConfigurationCompilerPlugInAggregationMultiFunction, Type> configPair = importService
                .ResolveAggregationMultiFunction(functionName, classProvidedExtension);
            if (configPair != null) {
                HashableMultiKey multiKey = new HashableMultiKey(configPair.First.FunctionNames);
                AggregationMultiFunctionForge factory = plugInAggregations.Map.Get(multiKey);
                if (factory == null) {
                    if (configPair.Second != null) {
                        factory = (AggregationMultiFunctionForge) TypeHelper.Instantiate<AggregationMultiFunctionForge>(
                            configPair.Second);
                    } else {
                        factory = (AggregationMultiFunctionForge) TypeHelper.Instantiate<AggregationMultiFunctionForge>(
                            configPair.First.MultiFunctionForgeClassName, importService.ClassForNameProvider);
                    }
                    plugInAggregations.Map[multiKey] = factory;
                }
                factory.AddAggregationFunction(new AggregationMultiFunctionDeclarationContext(
                    functionName.ToLowerInvariant(),
                    distinct,
                    configPair.First));
                return new ExprPlugInMultiFunctionAggNode(distinct, configPair.First, factory, functionName);
            }

            // try built-in expanded set of aggregation functions
            return importService.ResolveAggExtendedBuiltin(functionName, distinct);
        }
Пример #8
0
        public void TestTwoSeparateEntryElement()
        {
            var list1 = new List <EventBean>();

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

            testMap.Put(keyB, list1);
            var list2 = new List <EventBean>();

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

            testMap.Put(keyA, list2); // Actually before list1

            IEnumerator <EventBean> enumerator = testMap.GetMultiLevelEnumerator();

            EPAssertionUtil.AssertEqualsExactOrder(new[] { events.Get("b"), events.Get("a") }, enumerator);
        }
Пример #9
0
        public void TestIndex()
        {
            FilterParamIndexIn index = new FilterParamIndexIn(
                MakeLookupable("LongBoxed"),
                new SlimReaderWriterLock());

            Assert.AreEqual(FilterOperator.IN_LIST_OF_VALUES, index.FilterOperator);

            HashableMultiKey inList = new HashableMultiKey(new object[] { 2L, 5L });

            index.Put(inList, testEvaluator);
            inList = new HashableMultiKey(new object[] { 10L, 5L });
            index.Put(inList, testEvaluator);

            Verify(index, 1L, 0);
            Verify(index, 2L, 1);
            Verify(index, 5L, 2);
            Verify(index, 10L, 1);
            Verify(index, 999L, 0);
            Verify(index, null, 0);

            Assert.AreEqual(testEvaluator, index.Get(inList));
            Assert.IsTrue(index.ReadWriteLock != null);
            index.Remove(inList);
            index.Remove(inList);
            Assert.AreEqual(null, index.Get(inList));

            try
            {
                index.Put("a", testEvaluator);
                Assert.IsTrue(false);
            }
            catch (Exception)
            {
                // Expected
            }
        }