Esempio n. 1
0
        /// <summary>
        /// Compares only the type and filter portion and not the property evaluation portion.
        /// </summary>
        /// <param name="other">filter to compare</param>
        /// <returns>
        /// true if same
        /// </returns>
        public bool EqualsTypeAndFilter(FilterSpecCompiled other)
        {
            if (_filterForEventType != other._filterForEventType)
            {
                return(false);
            }

            if (_parameters.Length != other._parameters.Length)
            {
                return(false);
            }

            for (var i = 0; i < _parameters.Length; i++)
            {
                FilterSpecParam[] lineThis  = this.Parameters[i];
                FilterSpecParam[] lineOther = other.Parameters[i];
                if (lineThis.Length != lineOther.Length)
                {
                    return(false);
                }

                for (int j = 0; j < lineThis.Length; j++)
                {
                    if (!Equals(lineThis[j], lineOther[j]))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
        public void TestGetValueSet()
        {
            IList <FilterSpecParam> parameters = SupportFilterSpecBuilder.BuildList(_eventType, new Object[]
                                                                                    { "IntPrimitive", FilterOperator.EQUAL, 2 });
            var numberCoercer = CoercerFactory.GetCoercer(typeof(int), typeof(double));

            parameters.Add(new FilterSpecParamEventProp(MakeLookupable("DoubleBoxed"), FilterOperator.EQUAL, "asName", "DoublePrimitive", false, numberCoercer, typeof(double?), "Test"));
            FilterSpecCompiled filterSpec = new FilterSpecCompiled(_eventType, "SupportBean", new IList <FilterSpecParam>[] { parameters }, null);

            SupportBean eventBean = new SupportBean();

            eventBean.DoublePrimitive = 999.999;
            EventBean       theEvent      = SupportEventBeanFactory.CreateObject(eventBean);
            MatchedEventMap matchedEvents = new MatchedEventMapImpl(new MatchedEventMapMeta(new String[] { "asName" }, false));

            matchedEvents.Add(0, theEvent);
            FilterValueSet valueSet = filterSpec.GetValueSet(matchedEvents, null, null);

            // Assert the generated filter value container
            Assert.AreSame(_eventType, valueSet.EventType);
            Assert.AreEqual(2, valueSet.Parameters[0].Length);

            // Assert the first param
            var param = valueSet.Parameters[0][0];

            Assert.AreEqual("IntPrimitive", param.Lookupable.Expression);
            Assert.AreEqual(FilterOperator.EQUAL, param.FilterOperator);
            Assert.AreEqual(2, param.FilterForValue);

            // Assert the second param
            param = (FilterValueSetParam)valueSet.Parameters[0][1];
            Assert.AreEqual("DoubleBoxed", param.Lookupable.Expression);
            Assert.AreEqual(FilterOperator.EQUAL, param.FilterOperator);
            Assert.AreEqual(999.999, param.FilterForValue);
        }
Esempio n. 3
0
        public void TestEquals()
        {
            Object[][] paramList =
            {
                new Object[] { "IntPrimitive", FilterOperator.EQUAL,        2, "IntBoxed", FilterOperator.EQUAL, 3 },
                new Object[] { "IntPrimitive", FilterOperator.EQUAL,        3, "IntBoxed", FilterOperator.EQUAL, 3 },
                new Object[] { "IntPrimitive", FilterOperator.EQUAL,      2 },
                new Object[] { "IntPrimitive", FilterOperator.RANGE_CLOSED, 1,       10 },
                new Object[] { "IntPrimitive", FilterOperator.EQUAL,        2, "IntBoxed", FilterOperator.EQUAL, 3 },
                new Object[] { },
                new Object[] { },
            };

            var specVec = new List <FilterSpecCompiled>();

            foreach (Object[] param in paramList)
            {
                FilterSpecCompiled spec = SupportFilterSpecBuilder.Build(_eventType, param);
                specVec.Add(spec);
            }

            Assert.IsFalse(specVec[0].Equals(specVec[1]));
            Assert.IsFalse(specVec[0].Equals(specVec[2]));
            Assert.IsFalse(specVec[0].Equals(specVec[3]));
            Assert.AreEqual(specVec[0], specVec[4]);
            Assert.IsFalse(specVec[0].Equals(specVec[5]));
            Assert.AreEqual(specVec[5], specVec[6]);

            Assert.IsFalse(specVec[2].Equals(specVec[4]));
        }
Esempio n. 4
0
        public void TestPresortParameters()
        {
            FilterSpecCompiled spec = MakeFilterValues(
                "DoublePrimitive", FilterOperator.LESS, 1.1,
                "DoubleBoxed", FilterOperator.LESS, 1.1,
                "IntPrimitive", FilterOperator.EQUAL, 1,
                "string", FilterOperator.EQUAL, "jack",
                "IntBoxed", FilterOperator.EQUAL, 2,
                "FloatBoxed", FilterOperator.RANGE_CLOSED, 1.1d, 2.2d);

            LinkedList <FilterSpecParam> copy = new LinkedList <FilterSpecParam>(spec.Parameters[0]);

            Assert.AreEqual("IntPrimitive", copy.PopFront().Lookupable.Expression);
            Assert.AreEqual("string", copy.PopFront().Lookupable.Expression);
            Assert.AreEqual("IntBoxed", copy.PopFront().Lookupable.Expression);
            Assert.AreEqual("FloatBoxed", copy.PopFront().Lookupable.Expression);
            Assert.AreEqual("DoublePrimitive", copy.PopFront().Lookupable.Expression);
            Assert.AreEqual("DoubleBoxed", copy.PopFront().Lookupable.Expression);
        }
Esempio n. 5
0
        public static FilterSpecCompiled BuildNoStmtCtx(
            IList <ExprNode> validatedFilterNodes,
            EventType eventType,
            string eventTypeName,
            PropertyEvalSpec optionalPropertyEvalSpec,
            IDictionary <string, Pair <EventType, string> > taggedEventTypes,
            IDictionary <string, Pair <EventType, string> > arrayEventTypes,
            StreamTypeService streamTypeService,
            string optionalStreamName,
            ICollection <int> assignedTypeNumberStack,
            ExprEvaluatorContext exprEvaluatorContext,
            string statementId,
            string statementName,
            Attribute[] annotations,
            ContextDescriptor contextDescriptor,
            MethodResolutionService methodResolutionService,
            EventAdapterService eventAdapterService,
            TimeProvider timeProvider,
            VariableService variableService,
            ScriptingService scriptingService,
            TableService tableService,
            ConfigurationInformation configurationInformation,
            NamedWindowService namedWindowService)
        {
            var args = new FilterSpecCompilerArgs(
                taggedEventTypes,
                arrayEventTypes,
                exprEvaluatorContext,
                statementName,
                statementId,
                streamTypeService,
                methodResolutionService,
                timeProvider,
                variableService,
                tableService,
                eventAdapterService,
                scriptingService,
                annotations,
                contextDescriptor,
                configurationInformation);
            var parameters = FilterSpecCompilerPlanner.PlanFilterParameters(validatedFilterNodes, args);

            PropertyEvaluator optionalPropertyEvaluator = null;

            if (optionalPropertyEvalSpec != null)
            {
                optionalPropertyEvaluator = PropertyEvaluatorFactory.MakeEvaluator(
                    optionalPropertyEvalSpec,
                    eventType,
                    optionalStreamName,
                    eventAdapterService,
                    methodResolutionService,
                    timeProvider,
                    variableService,
                    scriptingService,
                    tableService,
                    streamTypeService.EngineURIQualifier,
                    statementId,
                    statementName,
                    annotations,
                    assignedTypeNumberStack,
                    configurationInformation,
                    namedWindowService);
            }

            var spec = new FilterSpecCompiled(eventType, eventTypeName, parameters, optionalPropertyEvaluator);

            if (Log.IsDebugEnabled)
            {
                Log.Debug(".makeFilterSpec spec=" + spec);
            }

            return(spec);
        }