public FragmentEventType GetFragmentType(string property)
        {
            lock (this) {
                var pair = propertyFragmentTypes.Get(property);
                if (pair == null) {
                    if (propertyFragmentTypes.ContainsKey(property)) {
                        return null;
                    }

                    return DoResolveFragmentType(property);
                }

                // if a type is assigned, use that
                if (pair.Second != null) {
                    return pair.Second;
                }

                // resolve event type
                var existingType = EventTypeResolver.GetTypeByName(pair.First.OptionalFragmentTypeName);
                if (!(existingType is BaseConfigurableEventType)) {
                    Log.Warn(
                        "Type configured for fragment event property '" +
                        property +
                        "' by name '" +
                        pair.First +
                        "' could not be found");
                    return null;
                }

                var fragmentType = new FragmentEventType(existingType, pair.First.IsFragmentArray, false);
                pair.Second = fragmentType;
                return fragmentType;
            }
        }
Esempio n. 2
0
        private void RunAssertionNewWRepresentation(EventRepresentationChoice rep)
        {
            string epl = rep.GetAnnotationText() + "select new { theString = 'x' || theString || 'x', intPrimitive = intPrimitive + 2} as val0 from SupportBean as sb";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.AddListener(_listener);

            Assert.AreEqual(rep.IsAvroEvent() ? typeof(GenericRecord) : typeof(Map), stmt.EventType.GetPropertyType("val0"));
            FragmentEventType fragType = stmt.EventType.GetFragmentType("val0");

            Assert.IsFalse(fragType.IsIndexed);
            Assert.IsFalse(fragType.IsNative);
            Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("theString"));
            Assert.AreEqual(typeof(int?), TypeHelper.GetBoxedType(fragType.FragmentType.GetPropertyType("intPrimitive")));

            string[] fieldsInner = "theString,intPrimitive".Split(',');
            _epService.EPRuntime.SendEvent(new SupportBean("E1", -5));
            EventBean @event = _listener.AssertOneGetNewAndReset();

            if (rep.IsAvroEvent())
            {
                SupportAvroUtil.AvroToJson(@event);
                var inner = (GenericRecord)@event.Get("val0");
                Assert.AreEqual("xE1x", inner.Get("theString"));
                Assert.AreEqual(-3, inner.Get("intPrimitive"));
            }
            else
            {
                EPAssertionUtil.AssertPropsMap((Map)@event.Get("val0"), fieldsInner, new Object[] { "xE1x", -3 });
            }

            stmt.Dispose();
        }
Esempio n. 3
0
        public override EventType GetEventTypeCollection(EventAdapterService eventAdapterService, string statementId)
        {
            var selectClause = SelectClause;
            var rawEventType = RawEventType;

            if (selectClause == null)         // wildcards allowed
            {
                return(rawEventType);
            }

            // special case: selecting a single property that is itself an event
            if (selectClause.Length == 1 && selectClause[0] is ExprIdentNode)
            {
                ExprIdentNode     identNode = (ExprIdentNode)selectClause[0];
                FragmentEventType fragment  = rawEventType.GetFragmentType(identNode.ResolvedPropertyName);
                if (fragment != null && !fragment.IsIndexed)
                {
                    return(fragment.FragmentType);
                }
            }

            // select of a single value otherwise results in a collection of scalar values
            if (selectClause.Length == 1)
            {
                return(null);
            }

            // fully-aggregated always returns zero or one row
            if (SubselectAggregationType == SubqueryAggregationType.FULLY_AGGREGATED)
            {
                return(null);
            }

            return(GetAssignAnonymousType(eventAdapterService, statementId));
        }
Esempio n. 4
0
 /// <summary>Ctor. </summary>
 /// <param name="containedEventEval">property getter or other evaluator</param>
 /// <param name="fragmentEventType">property event type</param>
 /// <param name="filter">optional where-clause expression</param>
 /// <param name="expressionText">the property name</param>
 public PropertyEvaluatorSimple(ContainedEventEval containedEventEval, FragmentEventType fragmentEventType, ExprEvaluator filter, String expressionText)
 {
     _fragmentEventType  = fragmentEventType;
     _containedEventEval = containedEventEval;
     _filter             = filter;
     _expressionText     = expressionText;
 }
Esempio n. 5
0
        private void RunAssertion(EPStatement stmt)
        {
            FragmentEventType fragmentType = stmt.EventType.GetFragmentType("subrow");

            Assert.IsFalse(fragmentType.IsIndexed);
            Assert.IsFalse(fragmentType.IsNative);
            Object[][] rows = new Object[][] {
                new Object[] { "v1", typeof(string) },
                new Object[] { "v2", typeof(int) },
            };
            for (int i = 0; i < rows.Length; i++)
            {
                String message = "Failed assertion for " + rows[i][0];
                EventPropertyDescriptor prop = fragmentType.FragmentType.PropertyDescriptors[i];
                Assert.AreEqual(rows[i][0], prop.PropertyName, message);
                Assert.AreEqual(rows[i][1], prop.PropertyType, message);
            }

            String[] fields = "subrow.v1,subrow.v2".Split(',');

            _epService.EPRuntime.SendEvent(new SupportBean_S0(1));
            EventBean theEvent = _listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertProps(theEvent, fields, new Object[] { null, null });

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 10));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(2));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1", 10 });

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 20));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(3));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E2", 20 });
        }
Esempio n. 6
0
        public FragmentEventType GetFragmentType(String property)
        {
            using (_iLock.Acquire())
            {
                Pair <ExplicitPropertyDescriptor, FragmentEventType> pair = _propertyFragmentTypes.Get(property);
                if (pair == null)
                {
                    return(_propertyFragmentTypes.ContainsKey(property) ? null : DoResolveFragmentType(property));
                }

                // if a type is assigned, use that
                if (pair.Second != null)
                {
                    return(pair.Second);
                }

                // resolve event type
                EventType existingType = _eventAdapterService.GetEventTypeByName(pair.First.OptionalFragmentTypeName);
                if (!(existingType is BaseConfigurableEventType))
                {
                    Log.Warn("Type configured for fragment event property '" + property + "' by name '" + pair.First +
                             "' could not be found");
                    return(null);
                }

                var fragmentType = new FragmentEventType(existingType, pair.First.IsFragmentArray, false);
                pair.Second = fragmentType;
                return(fragmentType);
            }
        }
Esempio n. 7
0
        private void RunAssertion(string epl)
        {
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.AddListener(_listener);
            Assert.AreEqual(typeof(IDictionary <string, object>), stmt.EventType.GetPropertyType("val0"));
            FragmentEventType fragType = stmt.EventType.GetFragmentType("val0");

            Assert.IsFalse(fragType.IsIndexed);
            Assert.IsFalse(fragType.IsNative);
            Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("col1"));
            Assert.AreEqual(typeof(int?), fragType.FragmentType.GetPropertyType("col2"));

            string[] fieldsInner = "col1,col2".Split(',');
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "Z", 30 });

            _epService.EPRuntime.SendEvent(new SupportBean("A", 2));
            EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "X", 10 });

            _epService.EPRuntime.SendEvent(new SupportBean("B", 3));
            EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "Y", 20 });

            _epService.EPRuntime.SendEvent(new SupportBean("C", 4));
            EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { null, null });

            stmt.Dispose();
        }
Esempio n. 8
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="streamName">is the stream name</param>
 /// <param name="streamEventType">is the event type of the stream where the property was found</param>
 /// <param name="propertyName">is the regular name of property</param>
 /// <param name="streamNum">is the number offset of the stream</param>
 /// <param name="propertyType">is the type of the property</param>
 /// <param name="fragmentEventType">Type of the fragment event.</param>
 public PropertyResolutionDescriptor(String streamName, EventType streamEventType, String propertyName, int streamNum, Type propertyType, FragmentEventType fragmentEventType)
 {
     StreamNum         = streamNum;
     StreamName        = streamName;
     StreamEventType   = streamEventType;
     PropertyName      = propertyName;
     PropertyType      = propertyType;
     FragmentEventType = fragmentEventType;
 }
Esempio n. 9
0
        private PropertyResolutionDescriptor FindByPropertyNameExplicitProps(String propertyName, bool obtainFragment)
        {
            var       index      = 0;
            var       foundIndex = 0;
            var       foundCount = 0;
            EventType streamType = null;

            for (var i = 0; i < _eventTypes.Length; i++)
            {
                if (_eventTypes[i] != null)
                {
                    var  descriptors  = _eventTypes[i].PropertyDescriptors;
                    Type propertyType = null;
                    var  found        = false;
                    FragmentEventType fragmentEventTypeX = null;

                    foreach (var desc in descriptors)
                    {
                        if (desc.PropertyName.Equals(propertyName))
                        {
                            propertyType = desc.PropertyType;
                            found        = true;
                            if (obtainFragment && desc.IsFragment)
                            {
                                fragmentEventTypeX = _eventTypes[i].GetFragmentType(propertyName);
                            }
                        }
                    }

                    if (found)
                    {
                        streamType = _eventTypes[i];
                        foundCount++;
                        foundIndex = index;

                        // If the property could be resolved from stream 0 then we don't need to look further
                        if ((i == 0) && _isStreamZeroUnambigous)
                        {
                            return(new PropertyResolutionDescriptor(_streamNames[0], _eventTypes[0], propertyName, 0, propertyType, fragmentEventTypeX));
                        }
                    }
                }
                index++;
            }

            HandleFindExceptions(propertyName, foundCount, streamType);

            FragmentEventType fragmentEventType = null;

            if (obtainFragment)
            {
                fragmentEventType = streamType.GetFragmentType(propertyName);
            }

            return(new PropertyResolutionDescriptor(_streamNames[foundIndex], _eventTypes[foundIndex], propertyName, foundIndex, streamType.GetPropertyType(propertyName), fragmentEventType));
        }
Esempio n. 10
0
        public FragmentEventType GetFragmentType(String property)
        {
            FragmentEventType fragment = _underlyingEventType.GetFragmentType(property);

            if (fragment != null)
            {
                return(fragment);
            }
            return(_underlyingMapType.GetFragmentType(property));
        }
 private static void AssertFragmentArray(EventBean @event, bool isNative, string propertyExpression)
 {
     var fragmentBean = (EventBean[]) @event.GetFragment(propertyExpression);
     FragmentEventType fragmentType = @event.EventType.GetFragmentType(propertyExpression);
     ScopeTestHelper.AssertTrue("failed for " + propertyExpression, fragmentType.IsIndexed);
     ScopeTestHelper.AssertEquals("failed for " + propertyExpression, isNative, fragmentType.IsNative);
     ScopeTestHelper.AssertSame(
         "failed for " + propertyExpression, fragmentBean[0].EventType, fragmentType.FragmentType);
     AssertConsistency(fragmentBean[0]);
 }
Esempio n. 12
0
        public static object ExtractFragmentTypeIsIndexed(EventPropertyDescriptor desc, EventType eventType)
        {
            FragmentEventType fragType = eventType.GetFragmentType(desc.PropertyName);

            if (fragType == null)
            {
                return(null);
            }
            return(fragType.IsIndexed);
        }
Esempio n. 13
0
 public ExprEvalByGetterFragment(
     int streamNum,
     EventPropertyGetterSPI getter,
     Type returnType,
     FragmentEventType fragmentType)
 {
     StreamNum = streamNum;
     Getter = getter;
     EvaluationType = returnType;
     this.fragmentType = fragmentType;
 }
Esempio n. 14
0
        private void AssertFragment(string prop, EventType eventType, string fragmentTypeName, bool indexed)
        {
            EventPropertyDescriptor desc = eventType.GetPropertyDescriptor(prop);

            Assert.AreEqual(true, desc.IsFragment);
            FragmentEventType fragment = eventType.GetFragmentType(prop);

            Assert.AreEqual(fragmentTypeName, fragment.FragmentType.Name);
            Assert.AreEqual(false, fragment.IsNative);
            Assert.AreEqual(indexed, fragment.IsIndexed);
        }
Esempio n. 15
0
 public PropertySetDescriptorItem(
     EventPropertyDescriptor propertyDescriptor,
     Type simplePropertyType,
     EventPropertyGetter propertyGetter,
     FragmentEventType fragmentEventType)
 {
     PropertyDescriptor = propertyDescriptor;
     SimplePropertyType = simplePropertyType;
     PropertyGetter     = propertyGetter;
     FragmentEventType  = fragmentEventType;
 }
Esempio n. 16
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="containedEventEval">property getter or other evaluator</param>
 /// <param name="fragmentEventType">property event type</param>
 /// <param name="filter">optional where-clause expression</param>
 /// <param name="expressionText">the property name</param>
 public PropertyEvaluatorSimpleForge(
     ContainedEventEvalForge containedEventEval,
     FragmentEventType fragmentEventType,
     ExprForge filter,
     string expressionText)
 {
     this.fragmentEventType = fragmentEventType;
     this.containedEventEval = containedEventEval;
     Filter = filter;
     ExpressionText = expressionText;
 }
Esempio n. 17
0
        private void AssertNestedElement(EventBean eventBean, String propertyName, String value)
        {
            FragmentEventType fragmentTypeOne = eventBean.EventType.GetFragmentType(propertyName);

            Assert.AreEqual(true, fragmentTypeOne.IsNative);
            Assert.AreEqual(false, fragmentTypeOne.IsIndexed);
            Assert.AreEqual(typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), fragmentTypeOne.FragmentType.UnderlyingType);

            EventBean theEvent = (EventBean)eventBean.GetFragment(propertyName);

            Assert.AreEqual(value, theEvent.Get("NestedValue"));
        }
Esempio n. 18
0
        private void Init()
        {
            _propertyNames = new string[_avroSchema.GetFields().Count];
            _propertyDescriptors = new EventPropertyDescriptor[_propertyNames.Length];
            int fieldNum = 0;

            foreach (Field field in _avroSchema.GetFields())
            {
                _propertyNames[fieldNum] = field.Name;

                Type propertyType = AvroTypeUtil.PropertyType(field.Schema);
                Type componentType = null;
                bool indexed = false;
                bool mapped = false;
                FragmentEventType fragmentEventType = null;

                if (field.Schema.Tag == global::Avro.Schema.Type.Array)
                {
                    componentType = AvroTypeUtil.PropertyType(field.Schema.GetElementType());
                    indexed = true;
                    if (field.Schema.GetElementType().Tag == global::Avro.Schema.Type.Record)
                    {
                        fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(field.Schema, _eventAdapterService);
                    }
                }
                else if (field.Schema.Tag == global::Avro.Schema.Type.Map)
                {
                    mapped = true;
                    componentType = AvroTypeUtil.PropertyType(field.Schema.GetValueType());
                }
                else if (field.Schema.Tag == global::Avro.Schema.Type.String)
                {
                    indexed = true;
                    componentType = typeof(char);
                    fragmentEventType = null;
                }
                else
                {
                    fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(field.Schema, _eventAdapterService);
                }

                var getter = new AvroEventBeanGetterSimple(
                    field, fragmentEventType == null ? null : fragmentEventType.FragmentType, _eventAdapterService);

                var descriptor = new EventPropertyDescriptor(
                    field.Name, propertyType, componentType, false, false, indexed, mapped, fragmentEventType != null);
                var item = new PropertySetDescriptorItem(descriptor, propertyType, getter, fragmentEventType);
                _propertyItems.Put(field.Name, item);
                _propertyDescriptors[fieldNum] = descriptor;

                fieldNum++;
            }
        }
Esempio n. 19
0
        private void AssertNestedCollection(EventBean eventBean, String propertyName, String prefix)
        {
            FragmentEventType fragmentTypeTwo = eventBean.EventType.GetFragmentType(propertyName);

            Assert.AreEqual(true, fragmentTypeTwo.IsNative);
            Assert.AreEqual(true, fragmentTypeTwo.IsIndexed);
            Assert.AreEqual(typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), fragmentTypeTwo.FragmentType.UnderlyingType);

            EventBean[] events = (EventBean[])eventBean.GetFragment(propertyName);
            Assert.AreEqual(2, events.Length);
            Assert.AreEqual(prefix + "N1", events[0].Get("NestedValue"));
            Assert.AreEqual(prefix + "N2", events[1].Get("NestedValue"));
        }
        private void RunAssertionFragment(EPServiceProvider epService)
        {
            string      stmtTxtOne = "select * from pattern [[2] a=A -> b=B]";
            EPStatement stmt       = epService.EPAdministrator.CreateEPL(stmtTxtOne);
            var         listener   = new SupportUpdateListener();

            stmt.Events += listener.Update;

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("a", typeof(SupportBean_A[]), typeof(SupportBean_A), false, false, true, false, true),
                new EventPropertyDescriptor("b", typeof(SupportBean_B), null, false, false, false, false, true)
            }, stmt.EventType.PropertyDescriptors);

            epService.EPRuntime.SendEvent(new SupportBean_A("A1"));
            epService.EPRuntime.SendEvent(new SupportBean_A("A2"));
            epService.EPRuntime.SendEvent(new SupportBean_B("B1"));

            EventBean theEvent = listener.AssertOneGetNewAndReset();

            Assert.IsTrue(theEvent.Underlying is IDictionary <string, object>);

            // test fragment B type and event
            FragmentEventType typeFragB = theEvent.EventType.GetFragmentType("b");

            Assert.IsFalse(typeFragB.IsIndexed);
            Assert.AreEqual("B", typeFragB.FragmentType.Name);
            Assert.AreEqual(typeof(string), typeFragB.FragmentType.GetPropertyType("id"));

            EventBean eventFragB = (EventBean)theEvent.GetFragment("b");

            Assert.AreEqual("B", eventFragB.EventType.Name);

            // test fragment A type and event
            FragmentEventType typeFragA = theEvent.EventType.GetFragmentType("a");

            Assert.IsTrue(typeFragA.IsIndexed);
            Assert.AreEqual("A", typeFragA.FragmentType.Name);
            Assert.AreEqual(typeof(string), typeFragA.FragmentType.GetPropertyType("id"));

            Assert.IsTrue(theEvent.GetFragment("a") is EventBean[]);
            EventBean eventFragA1 = (EventBean)theEvent.GetFragment("a[0]");

            Assert.AreEqual("A", eventFragA1.EventType.Name);
            Assert.AreEqual("A1", eventFragA1.Get("id"));
            EventBean eventFragA2 = (EventBean)theEvent.GetFragment("a[1]");

            Assert.AreEqual("A", eventFragA2.EventType.Name);
            Assert.AreEqual("A2", eventFragA2.Get("id"));

            stmt.Dispose();
        }
Esempio n. 21
0
        public EventBean GetEvent(XmlNode result)
        {
            if (_fragmentType == null)
            {
                FragmentEventType type = _xmlEventType.GetFragmentType(_propertyExpression);
                if (type == null)
                {
                    return(null);
                }
                _fragmentType = type.FragmentType;
            }

            return(_eventAdapterService.AdapterForTypedDOM(result, _fragmentType));
        }
Esempio n. 22
0
        public void RunAssertionNestableMapArray(EventRepresentationEnum eventRepresentationEnum)
        {
            EPStatement stmtInner = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyInnerType as (col1 string[], col2 int[])");
            EventType   inner     = stmtInner.EventType;

            Assert.AreEqual(typeof(string[]), inner.GetPropertyType("col1"));
            Assert.IsTrue(inner.GetPropertyDescriptor("col1").IsIndexed);
            Assert.AreEqual(typeof(int[]), inner.GetPropertyType("col2"));
            Assert.IsTrue(inner.GetPropertyDescriptor("col2").IsIndexed);
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), inner.UnderlyingType);

            EPStatement       stmtOuter = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyOuterType as (col1 MyInnerType, col2 MyInnerType[])");
            FragmentEventType type      = stmtOuter.EventType.GetFragmentType("col1");

            Assert.AreEqual("MyInnerType", type.FragmentType.Name);
            Assert.IsFalse(type.IsIndexed);
            Assert.IsFalse(type.IsNative);
            type = stmtOuter.EventType.GetFragmentType("col2");
            Assert.AreEqual("MyInnerType", type.FragmentType.Name);
            Assert.IsTrue(type.IsIndexed);
            Assert.IsFalse(type.IsNative);

            EPStatement stmtSelect = _epService.EPAdministrator.CreateEPL("select * from MyOuterType");

            stmtSelect.Events += _listener.Update;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtSelect.EventType.UnderlyingType);

            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                Object[] innerData = { "abc,def".Split(','), new int[] { 1, 2 } };
                Object[] outerData = { innerData, new Object[] { innerData, innerData } };
                _epService.EPRuntime.SendEvent(outerData, "MyOuterType");
            }
            else
            {
                IDictionary <String, Object> innerData = new Dictionary <String, Object>();
                innerData.Put("col1", "abc,def".Split(','));
                innerData.Put("col2", new int[] { 1, 2 });
                IDictionary <String, Object> outerData = new Dictionary <String, Object>();
                outerData.Put("col1", innerData);
                outerData.Put("col2", new DataMap[] { innerData, innerData });
                _epService.EPRuntime.SendEvent(outerData, "MyOuterType");
            }
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "col1.col1[1],col2[1].col2[1]".Split(','), new Object[] { "def", 2 });

            _epService.EPAdministrator.Configuration.RemoveEventType("MyInnerType", true);
            _epService.EPAdministrator.Configuration.RemoveEventType("MyOuterType", true);
            _epService.EPAdministrator.DestroyAllStatements();
        }
        private static void AssertConsistencyRecursive(EventType eventType, ISet<EventType> alreadySeenTypes)
        {
            if (alreadySeenTypes.Contains(eventType))
            {
                return;
            }
            alreadySeenTypes.Add(eventType);

            AssertConsistencyProperties(eventType);

            // test fragments
            foreach (EventPropertyDescriptor descriptor in eventType.PropertyDescriptors)
            {
                string failedMessage = "failed assertion for property '" + descriptor.PropertyName + "' ";
                if (!descriptor.IsFragment)
                {
                    ScopeTestHelper.AssertNull(failedMessage, eventType.GetFragmentType(descriptor.PropertyName));
                    continue;
                }

                FragmentEventType fragment = eventType.GetFragmentType(descriptor.PropertyName);
                if (!descriptor.RequiresIndex)
                {
                    ScopeTestHelper.AssertNotNull(failedMessage, fragment);
                    if (fragment.IsIndexed)
                    {
                        ScopeTestHelper.AssertTrue(descriptor.IsIndexed);
                    }
                    AssertConsistencyRecursive(fragment.FragmentType, alreadySeenTypes);
                }
                else
                {
                    fragment = eventType.GetFragmentType(descriptor.PropertyName + "[0]");
                    ScopeTestHelper.AssertNotNull(failedMessage, fragment);
                    ScopeTestHelper.AssertTrue(descriptor.IsIndexed);
                    AssertConsistencyRecursive(fragment.FragmentType, alreadySeenTypes);
                }
            }
        }
Esempio n. 24
0
        private void RunAssertionDefault(EPStatement stmt)
        {
            Assert.AreEqual(typeof(IDictionary <string, object>), stmt.EventType.GetPropertyType("val0"));
            FragmentEventType fragType = stmt.EventType.GetFragmentType("val0");

            Assert.IsFalse(fragType.IsIndexed);
            Assert.IsFalse(fragType.IsNative);
            Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("theString"));
            Assert.AreEqual(typeof(int?), fragType.FragmentType.GetPropertyType("intPrimitive"));
            Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("col2"));

            string[] fieldsInner = "theString,intPrimitive,col2".Split(',');
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { null, null, null });

            _epService.EPRuntime.SendEvent(new SupportBean("A", 2));
            EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "Q", 2, "AA" });

            _epService.EPRuntime.SendEvent(new SupportBean("B", 3));
            EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "B", 10, "BB" });

            stmt.Dispose();
        }
        public static EventBeanUpdateHelperForge Make(
            string updatedWindowOrTableName,
            EventTypeSPI eventTypeSPI,
            IList <OnTriggerSetAssignment> assignments,
            string updatedAlias,
            EventType optionalTriggeringEventType,
            bool isCopyOnWrite,
            string statementName,
            EventTypeAvroHandler avroHandler)
        {
            IList <EventBeanUpdateItemForge> updateItems = new List <EventBeanUpdateItemForge>();
            IList <string> properties = new List <string>();

            TypeWidenerCustomizer typeWidenerCustomizer = avroHandler.GetTypeWidenerCustomizer(eventTypeSPI);

            for (int i = 0; i < assignments.Count; i++)
            {
                OnTriggerSetAssignment desc       = assignments[i];
                ExprAssignment         assignment = desc.Validated;
                if (assignment == null)
                {
                    throw new IllegalStateException("Assignment has not been validated");
                }

                try {
                    EventBeanUpdateItemForge updateItem;
                    if (assignment is ExprAssignmentStraight)
                    {
                        ExprAssignmentStraight straight = (ExprAssignmentStraight)assignment;

                        // handle assignment "property = value"
                        if (straight.Lhs is ExprAssignmentLHSIdent)
                        {
                            ExprAssignmentLHSIdent ident = (ExprAssignmentLHSIdent)straight.Lhs;

                            string propertyName = ident.Ident;
                            EventPropertyDescriptor writableProperty = eventTypeSPI.GetWritableProperty(propertyName);

                            // check assignment to indexed or mapped property
                            if (writableProperty == null)
                            {
                                Pair <string, EventPropertyDescriptor> nameWriteablePair = CheckIndexedOrMappedProp(
                                    propertyName,
                                    updatedWindowOrTableName,
                                    updatedAlias,
                                    eventTypeSPI);
                                propertyName     = nameWriteablePair.First;
                                writableProperty = nameWriteablePair.Second;
                            }

                            ExprNode  rhsExpr             = straight.Rhs;
                            ExprForge rhsForge            = rhsExpr.Forge;
                            EventPropertyWriterSPI writer = eventTypeSPI.GetWriter(propertyName);
                            bool notNullableField         = writableProperty.PropertyType.IsPrimitive;

                            properties.Add(propertyName);
                            TypeWidenerSPI widener;
                            try {
                                widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(rhsExpr),
                                    rhsForge.EvaluationType,
                                    writableProperty.PropertyType,
                                    propertyName,
                                    false,
                                    typeWidenerCustomizer,
                                    statementName);
                            }
                            catch (TypeWidenerException ex) {
                                throw new ExprValidationException(ex.Message, ex);
                            }

                            // check event type assignment
                            bool useUntypedAssignment = false;
                            bool useTriggeringEvent   = false;
                            if (optionalTriggeringEventType != null)
                            {
                                // handle RHS is ident node
                                if (rhsExpr is ExprIdentNode)
                                {
                                    ExprIdentNode     node        = (ExprIdentNode)rhsExpr;
                                    FragmentEventType fragmentRHS = optionalTriggeringEventType.GetFragmentType(node.ResolvedPropertyName);
                                    FragmentEventType fragmentLHS = eventTypeSPI.GetFragmentType(propertyName);
                                    if (fragmentRHS != null && fragmentLHS != null)
                                    {
                                        if (!EventTypeUtility.IsTypeOrSubTypeOf(fragmentRHS.FragmentType, fragmentLHS.FragmentType))
                                        {
                                            throw MakeEventTypeMismatch(propertyName, fragmentLHS.FragmentType, fragmentRHS.FragmentType);
                                        }
                                    }

                                    // we don't need to cast if it is a self-assignment and LHS is an event and target needs no writer
                                    if (node.StreamId == 0 && fragmentLHS != null && eventTypeSPI is BaseNestableEventType)
                                    {
                                        useUntypedAssignment = true;
                                    }
                                }

                                // handle RHS is a stream of the triggering event itself
                                if (rhsExpr is ExprStreamUnderlyingNode)
                                {
                                    ExprStreamUnderlyingNode und = (ExprStreamUnderlyingNode)rhsExpr;
                                    if (und.StreamId == 1)
                                    {
                                        FragmentEventType fragmentLHS = eventTypeSPI.GetFragmentType(propertyName);
                                        if (fragmentLHS != null &&
                                            optionalTriggeringEventType is BaseNestableEventType &&
                                            !EventTypeUtility.IsTypeOrSubTypeOf(optionalTriggeringEventType, fragmentLHS.FragmentType))
                                        {
                                            throw MakeEventTypeMismatch(propertyName, fragmentLHS.FragmentType, optionalTriggeringEventType);
                                        }

                                        // we use the event itself for assignment and target needs no writer
                                        if (eventTypeSPI is BaseNestableEventType)
                                        {
                                            useUntypedAssignment = true;
                                            useTriggeringEvent   = true;
                                        }
                                    }
                                }
                            }

                            updateItem = new EventBeanUpdateItemForge(
                                rhsForge,
                                propertyName,
                                writer,
                                notNullableField,
                                widener,
                                useUntypedAssignment,
                                useTriggeringEvent,
                                null);
                        }
                        else if (straight.Lhs is ExprAssignmentLHSArrayElement)
                        {
                            // handle "property[expr] = value"
                            ExprAssignmentLHSArrayElement arrayElementLHS = (ExprAssignmentLHSArrayElement)straight.Lhs;
                            string   arrayPropertyName = arrayElementLHS.Ident;
                            ExprNode rhs            = straight.Rhs;
                            Type     evaluationType = rhs.Forge.EvaluationType;
                            Type     propertyType   = eventTypeSPI.GetPropertyType(arrayPropertyName);
                            if (!eventTypeSPI.IsProperty(arrayPropertyName))
                            {
                                throw new ExprValidationException("Property '" + arrayPropertyName + "' could not be found");
                            }

                            if (propertyType == null || !propertyType.IsArray)
                            {
                                throw new ExprValidationException("Property '" + arrayPropertyName + "' is not an array");
                            }

                            EventPropertyGetterSPI getter = eventTypeSPI.GetGetterSPI(arrayPropertyName);
                            Type componentType            = propertyType.GetElementType();
                            if (!TypeHelper.IsAssignmentCompatible(evaluationType, componentType))
                            {
                                throw new ExprValidationException(
                                          "Invalid assignment to property '" +
                                          arrayPropertyName +
                                          "' component type '" +
                                          componentType.CleanName() +
                                          "' from expression returning '" +
                                          evaluationType.CleanName() +
                                          "'");
                            }

                            TypeWidenerSPI widener;
                            try {
                                widener = TypeWidenerFactory.GetCheckPropertyAssignType(
                                    ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(straight.Rhs),
                                    evaluationType,
                                    componentType,
                                    arrayPropertyName,
                                    false,
                                    typeWidenerCustomizer,
                                    statementName);
                            }
                            catch (TypeWidenerException ex) {
                                throw new ExprValidationException(ex.Message, ex);
                            }

                            EventBeanUpdateItemArray arrayInfo = new EventBeanUpdateItemArray(
                                arrayPropertyName,
                                arrayElementLHS.IndexExpression,
                                propertyType,
                                getter);
                            updateItem = new EventBeanUpdateItemForge(
                                rhs.Forge,
                                arrayPropertyName,
                                null,
                                false,
                                widener,
                                false,
                                false,
                                arrayInfo);
                        }
                        else
                        {
                            throw new IllegalStateException("Unrecognized LHS assignment " + straight);
                        }
                    }
                    else if (assignment is ExprAssignmentCurly)
                    {
                        // handle non-assignment, i.e. UDF or other expression
                        ExprAssignmentCurly dot = (ExprAssignmentCurly)assignment;
                        updateItem = new EventBeanUpdateItemForge(
                            dot.Expression.Forge,
                            null,
                            null,
                            false,
                            null,
                            false,
                            false,
                            null);
                    }
                    else
                    {
                        throw new IllegalStateException("Unrecognized assignment " + assignment);
                    }

                    updateItems.Add(updateItem);
                }
                catch (ExprValidationException ex) {
                    throw new ExprValidationException(
                              "Failed to validate assignment expression '" +
                              ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceSafe(assignment.OriginalExpression) +
                              "': " +
                              ex.Message,
                              ex);
                }
            }

            // copy-on-write is the default event semantics as events are immutable
            EventBeanCopyMethodForge copyMethod;

            if (isCopyOnWrite)
            {
                // obtain copy method
                List <string> propertiesUniqueList = new List <string>(new HashSet <string>(properties));
                string[]      propertiesArray      = propertiesUniqueList.ToArray();
                copyMethod = eventTypeSPI.GetCopyMethodForge(propertiesArray);
                if (copyMethod == null)
                {
                    throw new ExprValidationException("Event type does not support event bean copy");
                }
            }
            else
            {
                // for in-place update, determine assignment expressions to use "initial" to access prior-change values
                // the copy-method is optional
                copyMethod = null;
                ISet <string> propertiesInitialValue = DeterminePropertiesInitialValue(assignments);
                if (!propertiesInitialValue.IsEmpty())
                {
                    string[] propertiesInitialValueArray = propertiesInitialValue.ToArray();
                    copyMethod = eventTypeSPI.GetCopyMethodForge(propertiesInitialValueArray);
                }
            }

            EventBeanUpdateItemForge[] updateItemsArray = updateItems.ToArray();
            return(new EventBeanUpdateHelperForge(eventTypeSPI, copyMethod, updateItemsArray));
        }
        private void RunAssertionXPathConfigured(string schemaURI, EPServiceProvider epService)
        {
            var rootMeta = new ConfigurationEventTypeXMLDOM();

            rootMeta.RootElementName = "simpleEvent";
            rootMeta.SchemaResource  = schemaURI;
            rootMeta.AddNamespacePrefix("ss", "samples:schemas:simpleSchema");
            rootMeta.AddXPathPropertyFragment("nested1simple", "/ss:simpleEvent/ss:nested1", XPathResultType.Any, "MyNestedEvent");
            rootMeta.AddXPathPropertyFragment("nested4array", "//ss:nested4", XPathResultType.NodeSet, "MyNestedArrayEvent");
            rootMeta.IsAutoFragment = false;
            epService.EPAdministrator.Configuration.AddEventType("MyXMLEvent", rootMeta);

            var metaNested = new ConfigurationEventTypeXMLDOM();

            metaNested.RootElementName = "//nested1";
            metaNested.SchemaResource  = schemaURI;
            metaNested.IsAutoFragment  = false;
            epService.EPAdministrator.Configuration.AddEventType("MyNestedEvent", metaNested);

            var metaNestedArray = new ConfigurationEventTypeXMLDOM();

            metaNestedArray.RootElementName = "//nested4";
            metaNestedArray.SchemaResource  = schemaURI;
            epService.EPAdministrator.Configuration.AddEventType("MyNestedArrayEvent", metaNestedArray);

            EPStatement stmtInsert   = epService.EPAdministrator.CreateEPL("insert into Nested3Stream select nested1simple, nested4array from MyXMLEvent#lastevent");
            EPStatement stmtWildcard = epService.EPAdministrator.CreateEPL("select * from MyXMLEvent#lastevent");

            SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType);
            SupportEventTypeAssertionUtil.AssertConsistency(stmtWildcard.EventType);
            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("nested1simple", typeof(XmlNode), null, false, false, false, false, true),
                new EventPropertyDescriptor("nested4array", typeof(XmlNode[]), typeof(XmlNode), false, false, true, false, true),
            }, stmtInsert.EventType.PropertyDescriptors);

            FragmentEventType fragmentTypeNested1 = stmtInsert.EventType.GetFragmentType("nested1simple");

            Assert.IsFalse(fragmentTypeNested1.IsIndexed);
            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("prop1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("prop2", typeof(bool?), null, false, false, false, false, false),
                new EventPropertyDescriptor("attr1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("nested2", typeof(XmlNode), null, false, false, false, false, false),
            }, fragmentTypeNested1.FragmentType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(fragmentTypeNested1.FragmentType);

            FragmentEventType fragmentTypeNested4 = stmtInsert.EventType.GetFragmentType("nested4array");

            Assert.IsTrue(fragmentTypeNested4.IsIndexed);
            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("prop5", typeof(string[]), typeof(string), false, false, true, false, false),
                new EventPropertyDescriptor("prop6", typeof(string[]), typeof(string), false, false, true, false, false),
                new EventPropertyDescriptor("prop7", typeof(string[]), typeof(string), false, false, true, false, false),
                new EventPropertyDescriptor("prop8", typeof(string[]), typeof(string), false, false, true, false, false),
                new EventPropertyDescriptor("id", typeof(string), typeof(char), false, false, true, false, false),
            }, fragmentTypeNested4.FragmentType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(fragmentTypeNested4.FragmentType);

            FragmentEventType fragmentTypeNested4Item = stmtInsert.EventType.GetFragmentType("nested4array[0]");

            Assert.IsFalse(fragmentTypeNested4Item.IsIndexed);
            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("prop5", typeof(string[]), typeof(string), false, false, true, false, false),
                new EventPropertyDescriptor("prop6", typeof(string[]), typeof(string), false, false, true, false, false),
                new EventPropertyDescriptor("prop7", typeof(string[]), typeof(string), false, false, true, false, false),
                new EventPropertyDescriptor("prop8", typeof(string[]), typeof(string), false, false, true, false, false),
                new EventPropertyDescriptor("id", typeof(string), typeof(char), false, false, true, false, false),
            }, fragmentTypeNested4Item.FragmentType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(fragmentTypeNested4Item.FragmentType);

            SupportXML.SendDefaultEvent(epService.EPRuntime, "ABC");

            EventBean received = stmtInsert.First();

            EPAssertionUtil.AssertProps(received, "nested1simple.prop1,nested1simple.prop2,nested1simple.attr1,nested1simple.nested2.prop3[1]".Split(','), new object[] { "SAMPLE_V1", true, "SAMPLE_ATTR1", 4 });
            EPAssertionUtil.AssertProps(received, "nested4array[0].id,nested4array[0].prop5[1],nested4array[1].id".Split(','), new object[] { "a", "SAMPLE_V8", "b" });

            // assert event and fragments alone
            EventBean wildcardStmtEvent = stmtWildcard.First();

            SupportEventTypeAssertionUtil.AssertConsistency(wildcardStmtEvent);

            FragmentEventType eventType = wildcardStmtEvent.EventType.GetFragmentType("nested1simple");

            Assert.IsFalse(eventType.IsIndexed);
            Assert.IsFalse(eventType.IsNative);
            Assert.AreEqual("MyNestedEvent", eventType.FragmentType.Name);
            Assert.IsTrue(wildcardStmtEvent.Get("nested1simple") is XmlNode);
            Assert.AreEqual("SAMPLE_V1", ((EventBean)wildcardStmtEvent.GetFragment("nested1simple")).Get("prop1"));

            eventType = wildcardStmtEvent.EventType.GetFragmentType("nested4array");
            Assert.IsTrue(eventType.IsIndexed);
            Assert.IsFalse(eventType.IsNative);
            Assert.AreEqual("MyNestedArrayEvent", eventType.FragmentType.Name);
            EventBean[] eventsArray = (EventBean[])wildcardStmtEvent.GetFragment("nested4array");
            Assert.AreEqual(3, eventsArray.Length);
            Assert.AreEqual("SAMPLE_V8", eventsArray[0].Get("prop5[1]"));
            Assert.AreEqual("SAMPLE_V9", eventsArray[1].Get("prop5[0]"));
            Assert.AreEqual(typeof(XmlNodeList), wildcardStmtEvent.EventType.GetPropertyType("nested4array"));
            Assert.IsTrue(wildcardStmtEvent.Get("nested4array") is XmlNodeList);

            EventBean nested4arrayItem = (EventBean)wildcardStmtEvent.GetFragment("nested4array[1]");

            Assert.AreEqual("b", nested4arrayItem.Get("id"));

            epService.EPAdministrator.DestroyAllStatements();
        }
Esempio n. 27
0
        public void TestCorrelatedAggregation()
        {
            String stmtText = "select p00, " +
                              "(select " +
                              "  sum(IntPrimitive) as v1, " +
                              "  sum(IntPrimitive + 1) as v2, " +
                              "  Window(IntPrimitive) as v3, " +
                              "  Window(sb.*) as v4 " +
                              "  from SupportBean#keepall sb " +
                              "  where TheString = s0.P00) as subrow " +
                              "from S0 as s0";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.Events += _listener.Update;

            Object[][] rows = new Object[][] {
                new Object[] { "p00", typeof(string), false },
                new Object[] { "subrow", typeof(Map), true }
            };
            for (int i = 0; i < rows.Length; i++)
            {
                String message = "Failed assertion for " + rows[i][0];
                EventPropertyDescriptor prop = stmt.EventType.PropertyDescriptors[i];
                Assert.AreEqual(rows[i][0], prop.PropertyName, message);
                Assert.AreEqual(rows[i][1], prop.PropertyType, message);
                Assert.AreEqual(rows[i][2], prop.IsFragment, message);
            }

            FragmentEventType fragmentType = stmt.EventType.GetFragmentType("subrow");

            Assert.IsFalse(fragmentType.IsIndexed);
            Assert.IsFalse(fragmentType.IsNative);
            rows = new Object[][] {
                new Object[] { "v1", typeof(int?) },
                new Object[] { "v2", typeof(int?) },
                new Object[] { "v3", typeof(int[]) },
                new Object[] { "v4", typeof(SupportBean[]) },
            };
            for (int i = 0; i < rows.Length; i++)
            {
                String message = "Failed assertion for " + rows[i][0];
                EventPropertyDescriptor prop = fragmentType.FragmentType.PropertyDescriptors[i];
                Assert.AreEqual(rows[i][0], prop.PropertyName, message);
                Assert.AreEqual(rows[i][1], prop.PropertyType, message);
            }

            String[] fields = "p00,subrow.v1,subrow.v2".Split(',');

            _epService.EPRuntime.SendEvent(new SupportBean_S0(1, "T1"));
            EventBean row = _listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertProps(row, fields, new Object[] { "T1", null, null });
            Assert.IsNull(row.Get("subrow.v3"));
            Assert.IsNull(row.Get("subrow.v4"));

            SupportBean sb1 = new SupportBean("T1", 10);

            _epService.EPRuntime.SendEvent(sb1);
            _epService.EPRuntime.SendEvent(new SupportBean_S0(2, "T1"));
            row = _listener.AssertOneGetNewAndReset();
            EPAssertionUtil.AssertProps(row, fields, new Object[] { "T1", 10, 11 });
            EPAssertionUtil.AssertEqualsAnyOrder(row.Get("subrow.v3").UnwrapIntoArray <int>(), new int[] { 10 });
            EPAssertionUtil.AssertEqualsAnyOrder(row.Get("subrow.v4").UnwrapIntoArray <object>(), new Object[] { sb1 });

            SupportBean sb2 = new SupportBean("T1", 20);

            _epService.EPRuntime.SendEvent(sb2);
            _epService.EPRuntime.SendEvent(new SupportBean_S0(3, "T1"));
            row = _listener.AssertOneGetNewAndReset();
            EPAssertionUtil.AssertProps(row, fields, new Object[] { "T1", 30, 32 });
            EPAssertionUtil.AssertEqualsAnyOrder(row.Get("subrow.v3").UnwrapIntoArray <int>(), new int[] { 10, 20 });
            EPAssertionUtil.AssertEqualsAnyOrder(row.Get("subrow.v4").UnwrapIntoArray <object>(), new Object[] { sb1, sb2 });
        }
Esempio n. 28
0
        public void TestXPathConfigured()
        {
            ConfigurationEventTypeXMLDOM rootMeta = new ConfigurationEventTypeXMLDOM();

            rootMeta.RootElementName = "simpleEvent";
            rootMeta.AddNamespacePrefix("ss", "samples:schemas:simpleSchema");
            rootMeta.AddXPathPropertyFragment("nested1simple", "/ss:simpleEvent/ss:nested1", XPathResultType.Any, "MyNestedEvent");
            rootMeta.AddXPathPropertyFragment("nested4array", "//ss:nested4", XPathResultType.NodeSet, "MyNestedArrayEvent");
            _epService.EPAdministrator.Configuration.AddEventType("MyXMLEvent", rootMeta);

            ConfigurationEventTypeXMLDOM metaNested = new ConfigurationEventTypeXMLDOM();

            metaNested.RootElementName = "nested1";
            _epService.EPAdministrator.Configuration.AddEventType("MyNestedEvent", metaNested);

            ConfigurationEventTypeXMLDOM metaNestedArray = new ConfigurationEventTypeXMLDOM();

            metaNestedArray.RootElementName = "nested4";
            _epService.EPAdministrator.Configuration.AddEventType("MyNestedArrayEvent", metaNestedArray);

            EPStatement stmtInsert   = _epService.EPAdministrator.CreateEPL("insert into Nested3Stream select nested1simple, nested4array from MyXMLEvent");
            EPStatement stmtWildcard = _epService.EPAdministrator.CreateEPL("select * from MyXMLEvent");

            SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType);
            SupportEventTypeAssertionUtil.AssertConsistency(stmtWildcard.EventType);
            EPAssertionUtil.AssertEqualsAnyOrder(
                new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("nested1simple", typeof(XmlNode), null, false, false, false, false, true),
                new EventPropertyDescriptor("nested4array", typeof(XmlNode[]), typeof(XmlNode), false, false, true, false, true),
            }, stmtInsert.EventType.PropertyDescriptors);

            FragmentEventType fragmentTypeNested1 = stmtInsert.EventType.GetFragmentType("nested1simple");

            Assert.IsFalse(fragmentTypeNested1.IsIndexed);
            Assert.AreEqual(0, fragmentTypeNested1.FragmentType.PropertyDescriptors.Count);
            SupportEventTypeAssertionUtil.AssertConsistency(fragmentTypeNested1.FragmentType);

            FragmentEventType fragmentTypeNested4 = stmtInsert.EventType.GetFragmentType("nested4array");

            Assert.IsTrue(fragmentTypeNested4.IsIndexed);
            Assert.AreEqual(0, fragmentTypeNested4.FragmentType.PropertyDescriptors.Count);
            SupportEventTypeAssertionUtil.AssertConsistency(fragmentTypeNested4.FragmentType);

            SupportXML.SendDefaultEvent(_epService.EPRuntime, "ABC");

            EventBean received = stmtInsert.First();

            EPAssertionUtil.AssertProps(received, "nested1simple.prop1,nested1simple.prop2,nested1simple.attr1,nested1simple.nested2.prop3[1]".SplitCsv(), new object[] { "SAMPLE_V1", "true", "SAMPLE_ATTR1", "4" });
            EPAssertionUtil.AssertProps(received, "nested4array[0].id,nested4array[0].prop5[1],nested4array[1].id".SplitCsv(), new object[] { "a", "SAMPLE_V8", "b" });

            // assert event and fragments alone
            EventBean wildcardStmtEvent = stmtWildcard.First();

            SupportEventTypeAssertionUtil.AssertConsistency(wildcardStmtEvent);

            FragmentEventType eventType = wildcardStmtEvent.EventType.GetFragmentType("nested1simple");

            Assert.IsFalse(eventType.IsIndexed);
            Assert.IsFalse(eventType.IsNative);
            Assert.AreEqual("MyNestedEvent", eventType.FragmentType.Name);
            Assert.IsTrue(wildcardStmtEvent.Get("nested1simple") is XmlNode);
            Assert.AreEqual("SAMPLE_V1", ((EventBean)wildcardStmtEvent.GetFragment("nested1simple")).Get("prop1"));

            eventType = wildcardStmtEvent.EventType.GetFragmentType("nested4array");
            Assert.IsTrue(eventType.IsIndexed);
            Assert.IsFalse(eventType.IsNative);
            Assert.AreEqual("MyNestedArrayEvent", eventType.FragmentType.Name);
            EventBean[] eventsArray = (EventBean[])wildcardStmtEvent.GetFragment("nested4array");
            Assert.AreEqual(3, eventsArray.Length);
            Assert.AreEqual("SAMPLE_V8", eventsArray[0].Get("prop5[1]"));
            Assert.AreEqual("SAMPLE_V9", eventsArray[1].Get("prop5[0]"));
            Assert.AreEqual(typeof(XmlNodeList), wildcardStmtEvent.EventType.GetPropertyType("nested4array"));
            Assert.IsTrue(wildcardStmtEvent.Get("nested4array") is XmlNodeList);
        }
Esempio n. 29
0
        private void Init()
        {
            var avroFields = _avroSchema.GetFields();

            _propertyNames = new string[avroFields.Count];
            _propertyDescriptors = new EventPropertyDescriptor[_propertyNames.Length];
            var fieldNum = 0;

            foreach (var field in avroFields) {
                _propertyNames[fieldNum] = field.Name;

                var propertyType = AvroTypeUtil.PropertyType(field.Schema).GetBoxedType();
                Type componentType = null;
                var indexed = false;
                var mapped = false;
                FragmentEventType fragmentEventType = null;

                if (field.Schema.Tag == global::Avro.Schema.Type.Array) {
                    componentType = AvroTypeUtil.PropertyType(field.Schema.AsArraySchema().ItemSchema);
                    indexed = true;
                    if (field.Schema.AsArraySchema().ItemSchema.Tag == global::Avro.Schema.Type.Record) {
                        fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(
                            field.Schema,
                            Metadata.ModuleName,
                            _eventBeanTypedEventFactory,
                            _eventTypeAvroHandler,
                            _fragmentTypeCache);
                    }
                }
                else if (field.Schema.Tag == global::Avro.Schema.Type.Map) {
                    mapped = true;
                    componentType = AvroTypeUtil.PropertyType(field.Schema.AsMapSchema().ValueSchema);
                }
                else if (field.Schema.Tag == global::Avro.Schema.Type.String) {
                    componentType = typeof(char);
                    indexed = true;
                }
                else {
                    fragmentEventType = AvroFragmentTypeUtil.GetFragmentEventTypeForField(
                        field.Schema,
                        Metadata.ModuleName,
                        _eventBeanTypedEventFactory,
                        _eventTypeAvroHandler,
                        _fragmentTypeCache);
                }

                var getter = new AvroEventBeanGetterSimple(
                    field,
                    fragmentEventType?.FragmentType,
                    _eventBeanTypedEventFactory,
                    propertyType);

                var descriptor = new EventPropertyDescriptor(
                    field.Name,
                    propertyType,
                    componentType,
                    false,
                    false,
                    indexed,
                    mapped,
                    fragmentEventType != null);
                var item = new PropertySetDescriptorItem(descriptor, propertyType, getter, fragmentEventType);
                _propertyItems.Put(field.Name, item);
                _propertyDescriptors[fieldNum] = descriptor;

                fieldNum++;
            }
        }
Esempio n. 30
0
        public override ExprNode Validate(ExprValidationContext validationContext)
        {
            // validate all parameters
            ExprNodeUtility.Validate(ExprNodeOrigin.DOTNODEPARAMETER, _chainSpec, validationContext);

            // determine if there are enumeration method expressions in the chain
            bool hasEnumerationMethod = false;

            foreach (ExprChainedSpec chain in _chainSpec)
            {
                if (chain.Name.IsEnumerationMethod())
                {
                    hasEnumerationMethod = true;
                    break;
                }
            }

            // determine if there is an implied binding, replace first chain element with evaluation node if there is
            if (validationContext.StreamTypeService.HasTableTypes &&
                validationContext.TableService != null &&
                _chainSpec.Count > 1 && _chainSpec[0].IsProperty)
            {
                Pair <ExprNode, IList <ExprChainedSpec> > tableNode =
                    validationContext.TableService.GetTableNodeChainable(
                        validationContext.StreamTypeService, _chainSpec,
                        validationContext.EngineImportService);
                if (tableNode != null)
                {
                    ExprNode node = ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.DOTNODE, tableNode.First, validationContext);
                    if (tableNode.Second.IsEmpty())
                    {
                        return(node);
                    }
                    _chainSpec.Clear();
                    _chainSpec.AddAll(tableNode.Second);
                    AddChildNode(node);
                }
            }

            // The root node expression may provide the input value:
            //   Such as "window(*).doIt(...)" or "(select * from Window).doIt()" or "prevwindow(sb).doIt(...)", in which case the expression to act on is a child expression
            //
            StreamTypeService streamTypeService = validationContext.StreamTypeService;

            if (ChildNodes.Length != 0)
            {
                // the root expression is the first child node
                ExprNode      rootNode          = ChildNodes[0];
                ExprEvaluator rootNodeEvaluator = rootNode.ExprEvaluator;

                // the root expression may also provide a lambda-function input (GetEnumerator<EventBean>)
                // Determine collection-type and evaluator if any for root node
                ExprDotEnumerationSource enumSrc = ExprDotNodeUtility.GetEnumerationSource(rootNode, validationContext.StreamTypeService, validationContext.EventAdapterService, validationContext.StatementId, hasEnumerationMethod, validationContext.IsDisablePropertyExpressionEventCollCache);

                EPType typeInfo;
                if (enumSrc.ReturnType == null)
                {
                    typeInfo = EPTypeHelper.SingleValue(rootNodeEvaluator.ReturnType);        // not a collection type, treat as scalar
                }
                else
                {
                    typeInfo = enumSrc.ReturnType;
                }

                ExprDotNodeRealizedChain evals = ExprDotNodeUtility.GetChainEvaluators(enumSrc.StreamOfProviderIfApplicable, typeInfo, _chainSpec, validationContext, _isDuckTyping, new ExprDotNodeFilterAnalyzerInputExpr());
                _exprEvaluator = new ExprDotEvalRootChild(hasEnumerationMethod, this, rootNodeEvaluator, enumSrc.Enumeration, typeInfo, evals.Chain, evals.ChainWithUnpack, false);
                return(null);
            }

            // No root node, and this is a 1-element chain i.e. "something(param,...)".
            // Plug-in single-row methods are not handled here.
            // Plug-in aggregation methods are not handled here.
            if (_chainSpec.Count == 1)
            {
                ExprChainedSpec spec = _chainSpec[0];
                if (spec.Parameters.IsEmpty())
                {
                    throw HandleNotFound(spec.Name);
                }

                // single-parameter can resolve to a property
                Pair <PropertyResolutionDescriptor, string> propertyInfoPair = null;
                try {
                    propertyInfoPair = ExprIdentNodeUtil.GetTypeFromStream(streamTypeService, spec.Name, streamTypeService.HasPropertyAgnosticType, false);
                }
                catch (ExprValidationPropertyException) {
                    // fine
                }

                // if not a property then try built-in single-row non-grammar functions
                if (propertyInfoPair == null && string.Equals(spec.Name, EngineImportServiceConstants.EXT_SINGLEROW_FUNCTION_TRANSPOSE, StringComparison.OrdinalIgnoreCase))
                {
                    if (spec.Parameters.Count != 1)
                    {
                        throw new ExprValidationException("The " + EngineImportServiceConstants.EXT_SINGLEROW_FUNCTION_TRANSPOSE + " function requires a single parameter expression");
                    }
                    _exprEvaluator = new ExprDotEvalTransposeAsStream(_chainSpec[0].Parameters[0].ExprEvaluator);
                }
                else if (spec.Parameters.Count != 1)
                {
                    throw HandleNotFound(spec.Name);
                }
                else
                {
                    if (propertyInfoPair == null)
                    {
                        throw new ExprValidationException("Unknown single-row function, aggregation function or mapped or indexed property named '" + spec.Name + "' could not be resolved");
                    }
                    _exprEvaluator       = GetPropertyPairEvaluator(spec.Parameters[0].ExprEvaluator, propertyInfoPair, validationContext);
                    _streamNumReferenced = propertyInfoPair.First.StreamNum;
                }
                return(null);
            }

            // handle the case where the first chain spec element is a stream name.
            ExprValidationException prefixedStreamNumException = null;
            int prefixedStreamNumber = PrefixedStreamName(_chainSpec, validationContext.StreamTypeService);

            if (prefixedStreamNumber != -1)
            {
                ExprChainedSpec specAfterStreamName = _chainSpec[1];

                // Attempt to resolve as property
                Pair <PropertyResolutionDescriptor, string> propertyInfoPair = null;
                try {
                    string propName = _chainSpec[0].Name + "." + specAfterStreamName.Name;
                    propertyInfoPair = ExprIdentNodeUtil.GetTypeFromStream(streamTypeService, propName, streamTypeService.HasPropertyAgnosticType, false);
                }
                catch (ExprValidationPropertyException) {
                    // fine
                }
                if (propertyInfoPair != null)
                {
                    if (specAfterStreamName.Parameters.Count != 1)
                    {
                        throw HandleNotFound(specAfterStreamName.Name);
                    }
                    _exprEvaluator       = GetPropertyPairEvaluator(specAfterStreamName.Parameters[0].ExprEvaluator, propertyInfoPair, validationContext);
                    _streamNumReferenced = propertyInfoPair.First.StreamNum;
                    return(null);
                }

                // Attempt to resolve as event-underlying object instance method
                EventType eventType = validationContext.StreamTypeService.EventTypes[prefixedStreamNumber];
                Type      type      = eventType.UnderlyingType;

                IList <ExprChainedSpec> remainderChain = new List <ExprChainedSpec>(_chainSpec);
                remainderChain.RemoveAt(0);

                ExprValidationException methodEx = null;
                ExprDotEval[]           underlyingMethodChain = null;
                try {
                    EPType typeInfo = EPTypeHelper.SingleValue(type);
                    underlyingMethodChain = ExprDotNodeUtility.GetChainEvaluators(prefixedStreamNumber, typeInfo, remainderChain, validationContext, false, new ExprDotNodeFilterAnalyzerInputStream(prefixedStreamNumber)).ChainWithUnpack;
                }
                catch (ExprValidationException ex) {
                    methodEx = ex;
                    // expected - may not be able to find the methods on the underlying
                }

                ExprDotEval[]           eventTypeMethodChain = null;
                ExprValidationException enumDatetimeEx       = null;
                try {
                    EPType typeInfo = EPTypeHelper.SingleEvent(eventType);
                    ExprDotNodeRealizedChain chain = ExprDotNodeUtility.GetChainEvaluators(prefixedStreamNumber, typeInfo, remainderChain, validationContext, false, new ExprDotNodeFilterAnalyzerInputStream(prefixedStreamNumber));
                    eventTypeMethodChain           = chain.ChainWithUnpack;
                    _exprDotNodeFilterAnalyzerDesc = chain.FilterAnalyzerDesc;
                }
                catch (ExprValidationException ex) {
                    enumDatetimeEx = ex;
                    // expected - may not be able to find the methods on the underlying
                }

                if (underlyingMethodChain != null)
                {
                    _exprEvaluator       = new ExprDotEvalStreamMethod(this, prefixedStreamNumber, underlyingMethodChain);
                    _streamNumReferenced = prefixedStreamNumber;
                }
                else if (eventTypeMethodChain != null)
                {
                    _exprEvaluator       = new ExprDotEvalStreamEventBean(this, prefixedStreamNumber, eventTypeMethodChain);
                    _streamNumReferenced = prefixedStreamNumber;
                }

                if (_exprEvaluator != null)
                {
                    return(null);
                }
                else
                {
                    if (ExprDotNodeUtility.IsDatetimeOrEnumMethod(remainderChain[0].Name))
                    {
                        prefixedStreamNumException = enumDatetimeEx;
                    }
                    else
                    {
                        prefixedStreamNumException = new ExprValidationException("Failed to solve '" + remainderChain[0].Name + "' to either a date-time or enumeration method, an event property or a method on the event underlying object: " + methodEx.Message, methodEx);
                    }
                }
            }

            // There no root node, in this case the classname or property name is provided as part of the chain.
            // Such as "MyClass.myStaticLib(...)" or "mycollectionproperty.doIt(...)"
            //
            IList <ExprChainedSpec> modifiedChain = new List <ExprChainedSpec>(_chainSpec);
            ExprChainedSpec         firstItem     = modifiedChain.Delete(0);

            Pair <PropertyResolutionDescriptor, string> propertyInfoPairX = null;

            try {
                propertyInfoPairX = ExprIdentNodeUtil.GetTypeFromStream(streamTypeService, firstItem.Name, streamTypeService.HasPropertyAgnosticType, true);
            }
            catch (ExprValidationPropertyException) {
                // not a property
            }

            // If property then treat it as such
            if (propertyInfoPairX != null)
            {
                string    propertyName = propertyInfoPairX.First.PropertyName;
                int       streamId     = propertyInfoPairX.First.StreamNum;
                EventType streamType   = streamTypeService.EventTypes[streamId];
                EPType    typeInfo;
                ExprEvaluatorEnumeration enumerationEval = null;
                EPType              inputType;
                ExprEvaluator       rootNodeEvaluator = null;
                EventPropertyGetter getter;

                if (firstItem.Parameters.IsEmpty())
                {
                    getter = streamType.GetGetter(propertyInfoPairX.First.PropertyName);

                    ExprDotEnumerationSourceForProps propertyEval = ExprDotNodeUtility.GetPropertyEnumerationSource(
                        propertyInfoPairX.First.PropertyName, streamId, streamType, hasEnumerationMethod, validationContext.IsDisablePropertyExpressionEventCollCache);
                    typeInfo          = propertyEval.ReturnType;
                    enumerationEval   = propertyEval.Enumeration;
                    inputType         = propertyEval.ReturnType;
                    rootNodeEvaluator = new PropertyExprEvaluatorNonLambda(streamId, getter, propertyInfoPairX.First.PropertyType);
                }
                else
                {
                    // property with parameter - mapped or indexed property
                    EventPropertyDescriptor desc = EventTypeUtility.GetNestablePropertyDescriptor(streamTypeService.EventTypes[propertyInfoPairX.First.StreamNum], firstItem.Name);
                    if (firstItem.Parameters.Count > 1)
                    {
                        throw new ExprValidationException("Property '" + firstItem.Name + "' may not be accessed passing 2 or more parameters");
                    }
                    ExprEvaluator paramEval = firstItem.Parameters[0].ExprEvaluator;
                    typeInfo  = EPTypeHelper.SingleValue(desc.PropertyComponentType);
                    inputType = typeInfo;
                    getter    = null;
                    if (desc.IsMapped)
                    {
                        if (paramEval.ReturnType != typeof(string))
                        {
                            throw new ExprValidationException("Parameter expression to mapped property '" + propertyName + "' is expected to return a string-type value but returns " + paramEval.ReturnType.GetTypeNameFullyQualPretty());
                        }
                        EventPropertyGetterMapped mappedGetter = propertyInfoPairX.First.StreamEventType.GetGetterMapped(propertyInfoPairX.First.PropertyName);
                        if (mappedGetter == null)
                        {
                            throw new ExprValidationException("Mapped property named '" + propertyName + "' failed to obtain getter-object");
                        }
                        rootNodeEvaluator = new PropertyExprEvaluatorNonLambdaMapped(streamId, mappedGetter, paramEval, desc.PropertyComponentType);
                    }
                    if (desc.IsIndexed)
                    {
                        if (paramEval.ReturnType.GetBoxedType() != typeof(int?))
                        {
                            throw new ExprValidationException("Parameter expression to mapped property '" + propertyName + "' is expected to return a Integer-type value but returns " + paramEval.ReturnType.GetTypeNameFullyQualPretty());
                        }
                        EventPropertyGetterIndexed indexedGetter = propertyInfoPairX.First.StreamEventType.GetGetterIndexed(propertyInfoPairX.First.PropertyName);
                        if (indexedGetter == null)
                        {
                            throw new ExprValidationException("Mapped property named '" + propertyName + "' failed to obtain getter-object");
                        }
                        rootNodeEvaluator = new PropertyExprEvaluatorNonLambdaIndexed(streamId, indexedGetter, paramEval, desc.PropertyComponentType);
                    }
                }
                if (typeInfo == null)
                {
                    throw new ExprValidationException("Property '" + propertyName + "' is not a mapped or indexed property");
                }

                // try to build chain based on the input (non-fragment)
                ExprDotNodeRealizedChain           evals;
                ExprDotNodeFilterAnalyzerInputProp filterAnalyzerInputProp = new ExprDotNodeFilterAnalyzerInputProp(propertyInfoPairX.First.StreamNum, propertyInfoPairX.First.PropertyName);
                bool rootIsEventBean = false;
                try {
                    evals = ExprDotNodeUtility.GetChainEvaluators(streamId, inputType, modifiedChain, validationContext, _isDuckTyping, filterAnalyzerInputProp);
                }
                catch (ExprValidationException ex) {
                    // try building the chain based on the fragment event type (i.e. A.after(B) based on A-configured start time where A is a fragment)
                    FragmentEventType fragment = propertyInfoPairX.First.FragmentEventType;
                    if (fragment == null)
                    {
                        throw;
                    }

                    EPType fragmentTypeInfo;
                    if (fragment.IsIndexed)
                    {
                        fragmentTypeInfo = EPTypeHelper.CollectionOfEvents(fragment.FragmentType);
                    }
                    else
                    {
                        fragmentTypeInfo = EPTypeHelper.SingleEvent(fragment.FragmentType);
                    }

                    rootIsEventBean   = true;
                    evals             = ExprDotNodeUtility.GetChainEvaluators(propertyInfoPairX.First.StreamNum, fragmentTypeInfo, modifiedChain, validationContext, _isDuckTyping, filterAnalyzerInputProp);
                    rootNodeEvaluator = new PropertyExprEvaluatorNonLambdaFragment(streamId, getter, fragment.FragmentType.UnderlyingType);
                }

                _exprEvaluator = new ExprDotEvalRootChild(hasEnumerationMethod, this, rootNodeEvaluator, enumerationEval, inputType, evals.Chain, evals.ChainWithUnpack, !rootIsEventBean);
                _exprDotNodeFilterAnalyzerDesc = evals.FilterAnalyzerDesc;
                _streamNumReferenced           = propertyInfoPairX.First.StreamNum;
                _rootPropertyName = propertyInfoPairX.First.PropertyName;
                return(null);
            }

            // If variable then resolve as such
            string contextNameVariable = validationContext.VariableService.IsContextVariable(firstItem.Name);

            if (contextNameVariable != null)
            {
                throw new ExprValidationException("Method invocation on context-specific variable is not supported");
            }
            VariableReader variableReader = validationContext.VariableService.GetReader(firstItem.Name, EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID);

            if (variableReader != null)
            {
                EPType typeInfo;
                ExprDotStaticMethodWrap wrap;
                if (variableReader.VariableMetaData.VariableType.IsArray)
                {
                    typeInfo = EPTypeHelper.CollectionOfSingleValue(variableReader.VariableMetaData.VariableType.GetElementType());
                    wrap     = new ExprDotStaticMethodWrapArrayScalar(variableReader.VariableMetaData.VariableName, variableReader.VariableMetaData.VariableType.GetElementType());
                }
                else if (variableReader.VariableMetaData.EventType != null)
                {
                    typeInfo = EPTypeHelper.SingleEvent(variableReader.VariableMetaData.EventType);
                    wrap     = null;
                }
                else
                {
                    typeInfo = EPTypeHelper.SingleValue(variableReader.VariableMetaData.VariableType);
                    wrap     = null;
                }

                ExprDotNodeRealizedChain evals = ExprDotNodeUtility.GetChainEvaluators(null, typeInfo, modifiedChain, validationContext, false, new ExprDotNodeFilterAnalyzerInputStatic());
                _exprEvaluator = new ExprDotEvalVariable(this, variableReader, wrap, evals.ChainWithUnpack);
                return(null);
            }

            // try resolve as enumeration class with value
            object enumconstant = TypeHelper.ResolveIdentAsEnumConst(firstItem.Name, validationContext.EngineImportService, false);

            if (enumconstant != null)
            {
                // try resolve method
                ExprChainedSpec methodSpec = modifiedChain[0];
                string          enumvalue  = firstItem.Name;
                ExprNodeUtilResolveExceptionHandler handler = new ProxyExprNodeUtilResolveExceptionHandler
                {
                    ProcHandle = ex => new ExprValidationException("Failed to resolve method '" + methodSpec.Name + "' on enumeration value '" + enumvalue + "': " + ex.Message),
                };
                EventType wildcardType            = validationContext.StreamTypeService.EventTypes.Length != 1 ? null : validationContext.StreamTypeService.EventTypes[0];
                ExprNodeUtilMethodDesc methodDesc =
                    ExprNodeUtility.ResolveMethodAllowWildcardAndStream(
                        enumconstant.GetType().Name, enumconstant.GetType(), methodSpec.Name, methodSpec.Parameters,
                        validationContext.EngineImportService, validationContext.EventAdapterService,
                        validationContext.StatementId, wildcardType != null, wildcardType, handler, methodSpec.Name,
                        validationContext.TableService);

                // method resolved, hook up
                modifiedChain.RemoveAt(0);        // we identified this piece
                ExprDotStaticMethodWrap optionalLambdaWrap = ExprDotStaticMethodWrapFactory.Make(methodDesc.ReflectionMethod, validationContext.EventAdapterService, modifiedChain);
                EPType typeInfo = optionalLambdaWrap != null ? optionalLambdaWrap.TypeInfo : EPTypeHelper.SingleValue(methodDesc.FastMethod.ReturnType);

                ExprDotNodeRealizedChain evals = ExprDotNodeUtility.GetChainEvaluators(null, typeInfo, modifiedChain, validationContext, false, new ExprDotNodeFilterAnalyzerInputStatic());
                _exprEvaluator = new ExprDotEvalStaticMethod(validationContext.StatementName, firstItem.Name, methodDesc.FastMethod,
                                                             methodDesc.ChildEvals, false, optionalLambdaWrap, evals.ChainWithUnpack, false, enumconstant);
                return(null);
            }

            // if prefixed by a stream name, we are giving up
            if (prefixedStreamNumException != null)
            {
                throw prefixedStreamNumException;
            }

            // If class then resolve as class
            ExprChainedSpec secondItem = modifiedChain.Delete(0);

            bool      allowWildcard  = validationContext.StreamTypeService.EventTypes.Length == 1;
            EventType streamZeroType = null;

            if (validationContext.StreamTypeService.EventTypes.Length > 0)
            {
                streamZeroType = validationContext.StreamTypeService.EventTypes[0];
            }

            ExprNodeUtilMethodDesc method = ExprNodeUtility.ResolveMethodAllowWildcardAndStream(
                firstItem.Name, null, secondItem.Name, secondItem.Parameters, validationContext.EngineImportService,
                validationContext.EventAdapterService, validationContext.StatementId, allowWildcard, streamZeroType,
                new ExprNodeUtilResolveExceptionHandlerDefault(firstItem.Name + "." + secondItem.Name, false),
                secondItem.Name, validationContext.TableService);

            bool isConstantParameters = method.IsAllConstants && _isUDFCache;

            _isReturnsConstantResult = isConstantParameters && modifiedChain.IsEmpty();

            // this may return a pair of null if there is no lambda or the result cannot be wrapped for lambda-function use
            ExprDotStaticMethodWrap optionalLambdaWrapX = ExprDotStaticMethodWrapFactory.Make(method.ReflectionMethod, validationContext.EventAdapterService, modifiedChain);
            EPType typeInfoX = optionalLambdaWrapX != null ? optionalLambdaWrapX.TypeInfo : EPTypeHelper.SingleValue(method.ReflectionMethod.ReturnType);

            ExprDotNodeRealizedChain evalsX = ExprDotNodeUtility.GetChainEvaluators(null, typeInfoX, modifiedChain, validationContext, false, new ExprDotNodeFilterAnalyzerInputStatic());

            _exprEvaluator = new ExprDotEvalStaticMethod(validationContext.StatementName, firstItem.Name, method.FastMethod, method.ChildEvals, isConstantParameters, optionalLambdaWrapX, evalsX.ChainWithUnpack, false, null);
            return(null);
        }