public WriteDesc(EventTypeSPI type, String variableName, EventPropertyWriter writer, EventPropertyGetter getter)
 {
     Type         = type;
     VariableName = variableName;
     Writer       = writer;
     Getter       = getter;
 }
예제 #2
0
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();
            ConfigurationVariantStream variant = new ConfigurationVariantStream();

            variant.TypeVariance = TypeVarianceEnum.ANY;
            config.AddVariantStream("MyVariantStream", variant);
            Assert.IsTrue(config.IsVariantStreamExists("MyVariantStream"));

            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            _listener = new SupportUpdateListener();

            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)_epService).ValueAddEventService.GetValueAddProcessor("MyVariantStream").ValueAddEventType;

            Assert.AreEqual(null, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("MyVariantStream", type.Metadata.PrimaryName);
            Assert.AreEqual("MyVariantStream", type.Metadata.PublicName);
            Assert.AreEqual("MyVariantStream", type.Name);
            Assert.AreEqual(TypeClass.VARIANT, type.Metadata.TypeClass);
            Assert.AreEqual(true, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfiguredStatic);

            EventType[] valueAddTypes = ((EPServiceProviderSPI)_epService).ValueAddEventService.ValueAddedTypes;
            Assert.AreEqual(1, valueAddTypes.Length);
            Assert.AreSame(type, valueAddTypes[0]);

            Assert.AreEqual(0, type.PropertyNames.Length);
            Assert.AreEqual(0, type.PropertyDescriptors.Count);
        }
        private void RunAssertionMetadata(EPServiceProvider epService)
        {
            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)epService).ValueAddEventService.GetValueAddProcessor("RevQuote").ValueAddEventType;

            Assert.AreEqual(null, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("RevisableQuote", type.Metadata.PrimaryName);
            Assert.AreEqual("RevisableQuote", type.Metadata.PublicName);
            Assert.AreEqual("RevisableQuote", type.Name);
            Assert.AreEqual(TypeClass.REVISION, type.Metadata.TypeClass);
            Assert.AreEqual(true, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfiguredStatic);

            EventType[] valueAddTypes = ((EPServiceProviderSPI)epService).ValueAddEventService.ValueAddedTypes;
            Assert.AreEqual(1, valueAddTypes.Length);
            Assert.AreSame(type, valueAddTypes[0]);

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("K0", typeof(string), null, false, false, false, false, false),
                new EventPropertyDescriptor("P0", typeof(string), null, false, false, false, false, false),
                new EventPropertyDescriptor("P1", typeof(string), null, false, false, false, false, false),
                new EventPropertyDescriptor("P2", typeof(string), null, false, false, false, false, false),
                new EventPropertyDescriptor("P3", typeof(string), null, false, false, false, false, false),
                new EventPropertyDescriptor("P4", typeof(string), null, false, false, false, false, false),
                new EventPropertyDescriptor("P5", typeof(string), null, false, false, false, false, false)
            }, type.PropertyDescriptors);
        }
예제 #4
0
        private void RunAssertionVariantTwoJoin(EPServiceProvider epService)
        {
            string stmtText = "insert into Event_1_2J " +
                              "select IntPrimitive - IntBoxed as delta, IntPrimitive * IntBoxed as product " +
                              "from " + typeof(SupportBean).FullName + "#length(100) as s0," +
                              typeof(SupportBean_A).FullName + "#length(100) as s1 " +
                              " where s0.TheString = s1.id";

            EPStatement stmt = TryAssertsVariant(epService, stmtText, null, "Event_1_2J");

            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)epService).EventAdapterService.GetEventTypeByName("Event_1_2J");

            Assert.AreEqual(null, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("Event_1_2J", type.Metadata.PrimaryName);
            Assert.AreEqual("Event_1_2J", type.Metadata.PublicName);
            Assert.AreEqual("Event_1_2J", type.Name);
            Assert.AreEqual(TypeClass.STREAM, type.Metadata.TypeClass);
            Assert.AreEqual(false, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(false, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(false, type.Metadata.IsApplicationPreConfiguredStatic);

            stmt.Dispose();
        }
예제 #5
0
        public OutputProcessViewDirectDistinctOrAfterFactory(
            StatementContext statementContext,
            OutputStrategyPostProcessFactory postProcessFactory,
            ResultSetProcessorHelperFactory resultSetProcessorHelperFactory,
            bool distinct,
            ExprTimePeriod afterTimePeriod,
            int?afterConditionNumberOfEvents,
            EventType resultEventType)
            : base(statementContext, postProcessFactory, resultSetProcessorHelperFactory)
        {
            _isDistinct     = distinct;
            AfterTimePeriod = afterTimePeriod;
            AfterConditionNumberOfEvents = afterConditionNumberOfEvents;

            if (_isDistinct)
            {
                if (resultEventType is EventTypeSPI)
                {
                    EventTypeSPI eventTypeSPI = (EventTypeSPI)resultEventType;
                    _eventBeanReader = eventTypeSPI.Reader;
                }
                if (_eventBeanReader == null)
                {
                    _eventBeanReader = new EventBeanReaderDefaultImpl(resultEventType);
                }
            }
        }
예제 #6
0
        private void AssertTypeExists(EPServiceProvider epService, String typeName, bool isPreconfigured)
        {
            EPServiceProviderSPI spi  = (EPServiceProviderSPI)epService;
            EventTypeSPI         type = (EventTypeSPI)spi.EventAdapterService.GetEventTypeByName(typeName);

            Assert.IsTrue(type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(isPreconfigured, type.Metadata.IsApplicationPreConfigured);
            Assert.IsFalse(type.Metadata.IsApplicationPreConfiguredStatic);
        }
예제 #7
0
 private static bool AllowPropulate(EventTypeSPI typeSPI)
 {
     if (!typeSPI.Metadata.IsApplicationConfigured &&
         typeSPI.Metadata.TypeClass != TypeClass.ANONYMOUS &&
         typeSPI.Metadata.TypeClass != TypeClass.TABLE)
     {
         return(false);
     }
     return(true);
 }
예제 #8
0
 public ExprIdentNodeEvaluatorContext(
     int streamNum,
     Type resultType,
     EventPropertyGetterSPI getter,
     EventTypeSPI eventType)
 {
     _streamNum = streamNum;
     _resultType = resultType;
     _getter = getter;
     _eventType = eventType;
 }
예제 #9
0
        public void SetUp()
        {
            _underlyingEventTypeOne         = new BeanEventType(null, 1, typeof(SupportBeanSimple), SupportEventAdapterService.Service, null);
            _underlyingEventTypeTwo         = new BeanEventType(null, 1, typeof(SupportBean_A), SupportEventAdapterService.Service, null);
            _properties                     = new Dictionary <String, Object>();
            _properties["additionalString"] = typeof(string);
            _properties["AdditionalInt"]    = typeof(int);
            _eventAdapterService            = SupportEventAdapterService.Service;
            EventTypeMetadata meta = EventTypeMetadata.CreateWrapper("test", true, false, false);

            _eventType = new WrapperEventType(meta, "mytype", 1, _underlyingEventTypeOne, _properties, _eventAdapterService);
        }
 public VariableTriggerWriteDescForge(
     EventTypeSPI type,
     string variableName,
     EventPropertyWriterSPI writer,
     EventPropertyGetterSPI getter,
     Type getterType,
     Type evaluationType)
 {
     Type = type;
     VariableName = variableName;
     Writer = writer;
     this.getter = getter;
     this.getterType = getterType;
     this.evaluationType = evaluationType;
 }
예제 #11
0
        public void TestInvalidRepeatedNames()
        {
            _properties.Clear();
            _properties["MyString"] = typeof(string);

            try
            {
                // The MyString property occurs in both the event and the map
                _eventType = new WrapperEventType(null, "mytype", 1, _underlyingEventTypeOne, _properties, _eventAdapterService);
                Assert.Fail();
            }
            catch (EPException ex)
            {
                // Expected
            }
        }
예제 #12
0
        public void TestTypeUpdate()
        {
            IDictionary <String, Object> typeOne = new Dictionary <String, Object>();

            typeOne["field1"] = typeof(string);
            MapEventType      underlying = new MapEventType(EventTypeMetadata.CreateAnonymous("noname", ApplicationType.MAP), "noname", 1, _eventAdapterService, typeOne, null, null, null);
            EventTypeMetadata meta       = EventTypeMetadata.CreateWrapper("test", true, false, false);

            _eventType = new WrapperEventType(meta, "mytype", 1, underlying, _properties, _eventAdapterService);

            EPAssertionUtil.AssertEqualsAnyOrder(new[] { "additionalString", "AdditionalInt", "field1" }, _eventType.PropertyNames);
            underlying.AddAdditionalProperties(Collections.SingletonDataMap("field2", typeof(string)), _eventAdapterService);
            EPAssertionUtil.AssertEqualsAnyOrder(new[] { "additionalString", "AdditionalInt", "field1", "field2" }, _eventType.PropertyNames);
            Assert.AreEqual(4, _eventType.PropertyDescriptors.Count);
            Assert.AreEqual(typeof(string), _eventType.GetPropertyDescriptor("field2").PropertyType);
        }
        public override void Run(EPServiceProvider epService)
        {
            var updateListener = new SupportUpdateListener();

            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)epService).EventAdapterService.GetEventTypeByName("TestXMLNoSchemaType");

            Assert.AreEqual(ApplicationType.XML, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("TestXMLNoSchemaType", type.Metadata.PrimaryName);
            Assert.AreEqual("TestXMLNoSchemaType", type.Metadata.PublicName);
            Assert.AreEqual("TestXMLNoSchemaType", type.Name);
            Assert.AreEqual(TypeClass.APPLICATION, type.Metadata.TypeClass);
            Assert.AreEqual(true, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfiguredStatic);

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("xpathElement1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("xpathCountE21", typeof(double?), null, false, false, false, false, false),
                new EventPropertyDescriptor("xpathAttrString", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("xpathAttrNum", typeof(double?), null, false, false, false, false, false),
                new EventPropertyDescriptor("xpathAttrBool", typeof(bool?), null, false, false, false, false, false),
                new EventPropertyDescriptor("stringCastLong", typeof(long?), null, false, false, false, false, false),
                new EventPropertyDescriptor("stringCastDouble", typeof(double?), null, false, false, false, false, false),
                new EventPropertyDescriptor("numCastInt", typeof(int?), null, false, false, false, false, false),
            }, type.PropertyDescriptors);

            string stmt =
                "select xpathElement1, xpathCountE21, xpathAttrString, xpathAttrNum, xpathAttrBool," +
                "stringCastLong," +
                "stringCastDouble," +
                "numCastInt " +
                "from TestXMLNoSchemaType#length(100)";

            EPStatement joinView = epService.EPAdministrator.CreateEPL(stmt);

            joinView.Events += updateListener.Update;

            // Generate document with the specified in element1 to confirm we have independent events
            SendEvent(epService, "EventA");
            AssertDataSimpleXPath(updateListener, "EventA");

            SendEvent(epService, "EventB");
            AssertDataSimpleXPath(updateListener, "EventB");
        }
예제 #14
0
 public ExprIdentNodeEvaluatorImpl(
     int streamNum,
     EventPropertyGetterSPI propertyGetter,
     Type returnType,
     ExprIdentNode identNode,
     EventTypeSPI eventType,
     bool optionalEvent,
     bool audit)
 {
     _streamNum = streamNum;
     _propertyGetter = propertyGetter;
     _identType = returnType;
     _returnType = returnType;
     _identNode = identNode;
     _eventType = eventType;
     _optionalEvent = optionalEvent;
     _audit = audit;
 }
예제 #15
0
        private void RunAssertionMetadata(EPServiceProvider epService)
        {
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)epService).EventAdapterService.GetEventTypeByName("myMapEvent");

            Assert.AreEqual(ApplicationType.MAP, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("myMapEvent", type.Metadata.PrimaryName);
            Assert.AreEqual("myMapEvent", type.Metadata.PublicName);
            Assert.AreEqual("myMapEvent", type.Name);
            Assert.AreEqual(TypeClass.APPLICATION, type.Metadata.TypeClass);
            Assert.AreEqual(true, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfiguredStatic);

            EPAssertionUtil.AssertEqualsAnyOrder(new[] {
                new EventPropertyDescriptor("myInt", typeof(int), null, false, false, false, false, false),
                new EventPropertyDescriptor("myString", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("beanA", typeof(SupportBeanComplexProps), null, false, false, false, false, true),
                new EventPropertyDescriptor("myStringArray", typeof(string[]), typeof(string), false, false, true, false, false),
            }, type.PropertyDescriptors);
        }
예제 #16
0
        private void RunAssertionMetadata(EPServiceProvider epService)
        {
            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)epService).ValueAddEventService.GetValueAddProcessor("MyVariantStream").ValueAddEventType;

            Assert.AreEqual(null, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("MyVariantStream", type.Metadata.PrimaryName);
            Assert.AreEqual("MyVariantStream", type.Metadata.PublicName);
            Assert.AreEqual("MyVariantStream", type.Name);
            Assert.AreEqual(TypeClass.VARIANT, type.Metadata.TypeClass);
            Assert.AreEqual(true, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfiguredStatic);

            EventType[] valueAddTypes = ((EPServiceProviderSPI)epService).ValueAddEventService.ValueAddedTypes;
            Assert.AreEqual(1, valueAddTypes.Length);
            Assert.AreSame(type, valueAddTypes[0]);

            Assert.AreEqual(0, type.PropertyNames.Length);
            Assert.AreEqual(0, type.PropertyDescriptors.Count);
        }
        private static Pair <string, EventPropertyDescriptor> CheckIndexedOrMappedProp(
            string propertyName,
            string updatedWindowOrTableName,
            string namedWindowAlias,
            EventTypeSPI eventTypeSPI)
        {
            EventPropertyDescriptor writableProperty = null;

            int indexDot = propertyName.IndexOf(".");

            if ((namedWindowAlias != null) && (indexDot != -1))
            {
                string prefix = StringValue.UnescapeBacktick(propertyName.Substring(0, indexDot));
                string name   = propertyName.Substring(indexDot + 1);
                if (prefix.Equals(namedWindowAlias))
                {
                    writableProperty = eventTypeSPI.GetWritableProperty(name);
                    propertyName     = name;
                }
            }

            if (writableProperty == null && indexDot != -1)
            {
                string prefix = propertyName.Substring(0, indexDot);
                string name   = propertyName.Substring(indexDot + 1);
                if (prefix.Equals(updatedWindowOrTableName))
                {
                    writableProperty = eventTypeSPI.GetWritableProperty(name);
                    propertyName     = name;
                }
            }

            if (writableProperty == null)
            {
                throw new ExprValidationException("Property '" + propertyName + "' is not available for write access");
            }

            return(new Pair <string, EventPropertyDescriptor>(propertyName, writableProperty));
        }
예제 #18
0
        public void TestModelPOCO()
        {
            EPStatement stmtCreateOne = _epService.EPAdministrator.CreateEPL("create schema SupportBeanOne as " + typeof(SupportBean).FullName);

            AssertTypeSupportBean(stmtCreateOne.EventType);

            EPStatement stmtCreateTwo = _epService.EPAdministrator.CreateEPL("create schema SupportBeanTwo as " + typeof(SupportBean).FullName);

            AssertTypeSupportBean(stmtCreateTwo.EventType);

            EPStatement stmtSelectOne = _epService.EPAdministrator.CreateEPL("select * from SupportBeanOne");

            AssertTypeSupportBean(stmtSelectOne.EventType);
            stmtSelectOne.Events += _listener.Update;

            EPStatement stmtSelectTwo = _epService.EPAdministrator.CreateEPL("select * from SupportBeanTwo");

            AssertTypeSupportBean(stmtSelectTwo.EventType);
            stmtSelectTwo.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 2));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetNewDataListFlattened(), "TheString,IntPrimitive".Split(','), new Object[][] { new Object[] { "E1", 2 }, new Object[] { "E1", 2 } });

            // assert type information
            EventTypeSPI typeSPI = (EventTypeSPI)stmtSelectOne.EventType;

            Assert.AreEqual(TypeClass.APPLICATION, typeSPI.Metadata.TypeClass);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PublicName);
            Assert.IsTrue(typeSPI.Metadata.IsApplicationConfigured);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfiguredStatic);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PrimaryName);

            // test keyword
            TryInvalid("create schema MySchema as com.mycompany.event.ABC",
                       "Error starting statement: Event type or class named 'com.mycompany.event.ABC' was not found [create schema MySchema as com.mycompany.event.ABC]");
            TryInvalid("create schema MySchema as com.mycompany.events.ABC",
                       "Error starting statement: Event type or class named 'com.mycompany.events.ABC' was not found [create schema MySchema as com.mycompany.events.ABC]");
        }
예제 #19
0
        public void TestSimpleXMLXPathProperties()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM();

            xmlDOMEventTypeDesc.RootElementName = "myevent";
            xmlDOMEventTypeDesc.AddXPathProperty("xpathElement1", "/myevent/element1", XPathResultType.String);
            xmlDOMEventTypeDesc.AddXPathProperty("xpathCountE21", "count(/myevent/element2/element21)", XPathResultType.Number);
            xmlDOMEventTypeDesc.AddXPathProperty("xpathAttrString", "/myevent/element3/@attrString", XPathResultType.String);
            xmlDOMEventTypeDesc.AddXPathProperty("xpathAttrNum", "/myevent/element3/@attrNum", XPathResultType.Number);
            xmlDOMEventTypeDesc.AddXPathProperty("xpathAttrBool", "/myevent/element3/@attrBool", XPathResultType.Boolean);
            xmlDOMEventTypeDesc.AddXPathProperty("stringCastLong", "/myevent/element3/@attrNum", XPathResultType.String, "long");
            xmlDOMEventTypeDesc.AddXPathProperty("stringCastDouble", "/myevent/element3/@attrNum", XPathResultType.String, "double");
            xmlDOMEventTypeDesc.AddXPathProperty("numCastInt", "/myevent/element3/@attrNum", XPathResultType.Number, "int");
            xmlDOMEventTypeDesc.XPathFunctionResolver = typeof(SupportXPathFunctionResolver).FullName;
            xmlDOMEventTypeDesc.XPathVariableResolver = typeof(SupportXPathVariableResolver).FullName;
            configuration.AddEventType("TestXMLNoSchemaType", xmlDOMEventTypeDesc);

            xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM();
            xmlDOMEventTypeDesc.RootElementName = "my.event2";
            configuration.AddEventType("TestXMLWithDots", xmlDOMEventTypeDesc);

            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            _updateListener = new SupportUpdateListener();

            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)_epService).EventAdapterService.GetEventTypeByName("TestXMLNoSchemaType");

            Assert.AreEqual(ApplicationType.XML, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("TestXMLNoSchemaType", type.Metadata.PrimaryName);
            Assert.AreEqual("TestXMLNoSchemaType", type.Metadata.PublicName);
            Assert.AreEqual("TestXMLNoSchemaType", type.Name);
            Assert.AreEqual(TypeClass.APPLICATION, type.Metadata.TypeClass);
            Assert.AreEqual(true, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfiguredStatic);

            EPAssertionUtil.AssertEqualsAnyOrder(new[] {
                new EventPropertyDescriptor("xpathElement1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("xpathCountE21", typeof(double?), null, false, false, false, false, false),
                new EventPropertyDescriptor("xpathAttrString", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("xpathAttrNum", typeof(double?), null, false, false, false, false, false),
                new EventPropertyDescriptor("xpathAttrBool", typeof(bool?), null, false, false, false, false, false),
                new EventPropertyDescriptor("stringCastLong", typeof(long), null, false, false, false, false, false),
                new EventPropertyDescriptor("stringCastDouble", typeof(double), null, false, false, false, false, false),
                new EventPropertyDescriptor("numCastInt", typeof(int), null, false, false, false, false, false),
            }, type.PropertyDescriptors);

            String stmt =
                "select xpathElement1, xpathCountE21, xpathAttrString, xpathAttrNum, xpathAttrBool," +
                "stringCastLong," +
                "stringCastDouble," +
                "numCastInt " +
                "from TestXMLNoSchemaType.win:length(100)";

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

            joinView.Events += _updateListener.Update;

            // Generate document with the specified in element1 to confirm we have independent events
            SendEvent("EventA");
            AssertDataSimpleXPath("EventA");

            SendEvent("EventB");
            AssertDataSimpleXPath("EventB");

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
예제 #20
0
        private void RunAssertionNoWildcardWithAs(EPServiceProvider epService)
        {
            // create window
            string      stmtTextCreate = "create window MyWindowNW#keepall as select TheString as a, LongPrimitive as b, LongBoxed as c from " + typeof(SupportBean).FullName;
            EPStatement stmtCreate     = epService.EPAdministrator.CreateEPL(stmtTextCreate);
            var         listenerWindow = new SupportUpdateListener();

            stmtCreate.Events += listenerWindow.Update;
            EPAssertionUtil.AssertEqualsAnyOrder(stmtCreate.EventType.PropertyNames, new string[] { "a", "b", "c" });
            Assert.AreEqual(typeof(string), stmtCreate.EventType.GetPropertyType("a"));
            Assert.AreEqual(typeof(long), stmtCreate.EventType.GetPropertyType("b"));
            Assert.AreEqual(typeof(long?), stmtCreate.EventType.GetPropertyType("c"));

            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)epService).EventAdapterService.GetEventTypeByName("MyWindowNW");

            Assert.AreEqual(null, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("MyWindowNW", type.Metadata.PrimaryName);
            Assert.AreEqual("MyWindowNW", type.Metadata.PublicName);
            Assert.AreEqual("MyWindowNW", type.Name);
            Assert.AreEqual(TypeClass.NAMED_WINDOW, type.Metadata.TypeClass);
            Assert.AreEqual(false, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(false, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(false, type.Metadata.IsApplicationPreConfiguredStatic);

            // create insert into
            string stmtTextInsertOne = "insert into MyWindowNW select TheString as a, LongPrimitive as b, LongBoxed as c from " + typeof(SupportBean).FullName;

            epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            string stmtTextInsertTwo = "insert into MyWindowNW select symbol as a, volume as b, volume as c from " + typeof(SupportMarketDataBean).FullName;

            epService.EPAdministrator.CreateEPL(stmtTextInsertTwo);

            string stmtTextInsertThree = "insert into MyWindowNW select key as a, boxed as b, primitive as c from MyMap";

            epService.EPAdministrator.CreateEPL(stmtTextInsertThree);

            // create consumer
            string      stmtTextSelectOne = "select a, b, c from MyWindowNW";
            EPStatement stmtSelectOne     = epService.EPAdministrator.CreateEPL(stmtTextSelectOne);
            var         listenerStmtOne   = new SupportUpdateListener();

            stmtSelectOne.Events += listenerStmtOne.Update;
            EPAssertionUtil.AssertEqualsAnyOrder(stmtSelectOne.EventType.PropertyNames, new string[] { "a", "b", "c" });
            Assert.AreEqual(typeof(string), stmtCreate.EventType.GetPropertyType("a"));
            Assert.AreEqual(typeof(long), stmtCreate.EventType.GetPropertyType("b"));
            Assert.AreEqual(typeof(long?), stmtCreate.EventType.GetPropertyType("c"));

            // create delete stmt
            string      stmtTextDelete     = "on " + typeof(SupportMarketDataBean).FullName + " as s0 delete from MyWindowNW as s1 where s0.symbol = s1.a";
            EPStatement stmtDelete         = epService.EPAdministrator.CreateEPL(stmtTextDelete);
            var         listenerStmtDelete = new SupportUpdateListener();

            stmtDelete.Events += listenerStmtDelete.Update;

            SendSupportBean(epService, "E1", 1L, 10L);
            var fields = new string[] { "a", "b", "c" };

            EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1L, 10L });
            EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1L, 10L });

            SendMarketBean(epService, "S1", 99L);
            EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "S1", 99L, 99L });
            EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "S1", 99L, 99L });

            SendMap(epService, "M1", 100L, 101L);
            EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "M1", 101L, 100L });
            EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "M1", 101L, 100L });

            epService.EPAdministrator.DestroyAllStatements();
        }
예제 #21
0
        private void RunAssertionCreateTableSyntax(EPServiceProvider epService)
        {
            // create window
            string      stmtTextCreate = "create window MyWindowCTS#keepall (stringValOne varchar, stringValTwo string, intVal int, longVal long)";
            EPStatement stmtCreate     = epService.EPAdministrator.CreateEPL(stmtTextCreate);
            var         listenerWindow = new SupportUpdateListener();

            stmtCreate.Events += listenerWindow.Update;

            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)epService).EventAdapterService.GetEventTypeByName("MyWindowCTS");

            Assert.AreEqual(null, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("MyWindowCTS", type.Metadata.PrimaryName);
            Assert.AreEqual("MyWindowCTS", type.Metadata.PublicName);
            Assert.AreEqual("MyWindowCTS", type.Name);
            Assert.AreEqual(TypeClass.NAMED_WINDOW, type.Metadata.TypeClass);
            Assert.AreEqual(false, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(false, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(false, type.Metadata.IsApplicationPreConfiguredStatic);

            // create insert into
            string stmtTextInsertOne = "insert into MyWindowCTS select TheString as stringValOne, TheString as stringValTwo, Cast(LongPrimitive, int) as intVal, LongBoxed as longVal from " + typeof(SupportBean).FullName;

            epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            // create consumer
            string      stmtTextSelectOne = "select stringValOne, stringValTwo, intVal, longVal from MyWindowCTS";
            EPStatement stmtSelectOne     = epService.EPAdministrator.CreateEPL(stmtTextSelectOne);
            var         listenerStmtOne   = new SupportUpdateListener();

            stmtSelectOne.Events += listenerStmtOne.Update;

            SendSupportBean(epService, "E1", 1L, 10L);
            string[] fields = "stringValOne,stringValTwo,intVal,longVal".Split(',');
            EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), fields, new object[] { "E1", "E1", 1, 10L });
            EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E1", "E1", 1, 10L });

            // create window with two views
            stmtTextCreate = "create window MyWindowCTSTwo#unique(stringValOne)#keepall (stringValOne varchar, stringValTwo string, intVal int, longVal long)";
            epService.EPAdministrator.CreateEPL(stmtTextCreate);

            //create window with statement object model
            string text = "create window MyWindowCTSThree#keepall as (a string, b integer, c integer)";
            EPStatementObjectModel model = epService.EPAdministrator.CompileEPL(text);

            Assert.AreEqual(text, model.ToEPL());
            stmtCreate = epService.EPAdministrator.Create(model);
            Assert.AreEqual(typeof(string), stmtCreate.EventType.GetPropertyType("a"));
            Assert.AreEqual(typeof(int), stmtCreate.EventType.GetPropertyType("b"));
            Assert.AreEqual(typeof(int), stmtCreate.EventType.GetPropertyType("c"));
            Assert.AreEqual(text, model.ToEPL());

            text  = "create window MyWindowCTSFour#unique(a)#unique(b) retain-union as (a string, b integer, c integer)";
            model = epService.EPAdministrator.CompileEPL(text);
            epService.EPAdministrator.Create(model);
            Assert.AreEqual(text, model.ToEPL());

            epService.EPAdministrator.DestroyAllStatements();
        }
예제 #22
0
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddEventType <SupportBean>();
            config.AddEventType("FullEvent", typeof(SupportRevisionFull));
            config.AddEventType("D1", typeof(SupportDeltaOne));
            config.AddEventType("D2", typeof(SupportDeltaTwo));
            config.AddEventType("D3", typeof(SupportDeltaThree));
            config.AddEventType("D4", typeof(SupportDeltaFour));
            config.AddEventType("D5", typeof(SupportDeltaFive));

            ConfigurationRevisionEventType configRev = new ConfigurationRevisionEventType();

            configRev.KeyPropertyNames = (new String[] { "K0" });
            configRev.AddNameBaseEventType("FullEvent");
            configRev.AddNameDeltaEventType("D1");
            configRev.AddNameDeltaEventType("D2");
            configRev.AddNameDeltaEventType("D3");
            configRev.AddNameDeltaEventType("D4");
            configRev.AddNameDeltaEventType("D5");
            config.AddRevisionEventType("RevisableQuote", configRev);

            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            _listenerOne   = new SupportUpdateListener();
            _listenerTwo   = new SupportUpdateListener();
            _listenerThree = new SupportUpdateListener();

            _stmtCreateWin = _epService.EPAdministrator.CreateEPL("create window RevQuote.win:keepall() as select * from RevisableQuote");
            _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from FullEvent");
            _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D1");
            _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D2");
            _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D3");
            _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D4");
            _epService.EPAdministrator.CreateEPL("insert into RevQuote select * from D5");

            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)_epService).ValueAddEventService.GetValueAddProcessor("RevQuote").ValueAddEventType;

            Assert.AreEqual(null, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, type.Metadata.OptionalSecondaryNames);
            Assert.AreEqual("RevisableQuote", type.Metadata.PrimaryName);
            Assert.AreEqual("RevisableQuote", type.Metadata.PublicName);
            Assert.AreEqual("RevisableQuote", type.Name);
            Assert.AreEqual(TypeClass.REVISION, type.Metadata.TypeClass);
            Assert.AreEqual(true, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(true, type.Metadata.IsApplicationPreConfiguredStatic);

            EventType[] valueAddTypes = ((EPServiceProviderSPI)_epService).ValueAddEventService.ValueAddedTypes;
            Assert.AreEqual(1, valueAddTypes.Length);
            Assert.AreSame(type, valueAddTypes[0]);

            EPAssertionUtil.AssertEqualsAnyOrder(new [] {
                new EventPropertyDescriptor("K0", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("P0", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("P1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("P2", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("P3", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("P4", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("P5", typeof(string), typeof(char), false, false, true, false, false)
            }, type.PropertyDescriptors);
        }
예제 #23
0
        public static EventBeanUpdateHelper Make(
            string updatedWindowOrTableName,
            EventTypeSPI eventTypeSPI,
            IList <OnTriggerSetAssignment> assignments,
            string updatedAlias,
            EventType optionalTriggeringEventType,
            bool isCopyOnWrite)
        {
            IList <EventBeanUpdateItem> updateItems = new List <EventBeanUpdateItem>();
            IList <string> properties = new List <string>();

            for (var i = 0; i < assignments.Count; i++)
            {
                var assignment = assignments[i];
                EventBeanUpdateItem updateItem;

                // determine whether this is a "property=value" assignment, we use property setters in this case
                var possibleAssignment = ExprNodeUtility.CheckGetAssignmentToProp(assignment.Expression);

                // handle assignment "property = value"
                if (possibleAssignment != null)
                {
                    var propertyName     = possibleAssignment.First;
                    var writableProperty = eventTypeSPI.GetWritableProperty(propertyName);

                    // check assignment to indexed or mapped property
                    if (writableProperty == null)
                    {
                        var nameWriteablePair = CheckIndexedOrMappedProp(possibleAssignment.First, updatedWindowOrTableName, updatedAlias, eventTypeSPI);
                        propertyName     = nameWriteablePair.First;
                        writableProperty = nameWriteablePair.Second;
                    }

                    var evaluator        = possibleAssignment.Second.ExprEvaluator;
                    var writers          = eventTypeSPI.GetWriter(propertyName);
                    var notNullableField = writableProperty.PropertyType.IsPrimitive;

                    properties.Add(propertyName);
                    var widener = TypeWidenerFactory.GetCheckPropertyAssignType(ExprNodeUtility.ToExpressionStringMinPrecedenceSafe(possibleAssignment.Second), possibleAssignment.Second.ExprEvaluator.ReturnType,
                                                                                writableProperty.PropertyType, propertyName);

                    // check event type assignment
                    if (optionalTriggeringEventType != null && possibleAssignment.Second is ExprIdentNode)
                    {
                        var node        = (ExprIdentNode)possibleAssignment.Second;
                        var fragmentRHS = optionalTriggeringEventType.GetFragmentType(node.ResolvedPropertyName);
                        var fragmentLHS = eventTypeSPI.GetFragmentType(possibleAssignment.First);
                        if (fragmentRHS != null && fragmentLHS != null && !EventTypeUtility.IsTypeOrSubTypeOf(fragmentRHS.FragmentType, fragmentLHS.FragmentType))
                        {
                            throw new ExprValidationException("Invalid assignment to property '" +
                                                              possibleAssignment.First + "' event type '" + fragmentLHS.FragmentType.Name +
                                                              "' from event type '" + fragmentRHS.FragmentType.Name + "'");
                        }
                    }

                    updateItem = new EventBeanUpdateItem(evaluator, propertyName, writers, notNullableField, widener);
                }
                // handle non-assignment, i.e. UDF or other expression
                else
                {
                    var evaluator = assignment.Expression.ExprEvaluator;
                    updateItem = new EventBeanUpdateItem(evaluator, null, null, false, null);
                }

                updateItems.Add(updateItem);
            }

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

            if (isCopyOnWrite)
            {
                // obtain copy method
                IList <string> propertiesUniqueList = new List <string>(new HashSet <string>(properties));
                var            propertiesArray      = propertiesUniqueList.ToArray();
                copyMethod = eventTypeSPI.GetCopyMethod(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;
                var propertiesInitialValue = DeterminePropertiesInitialValue(assignments);
                if (!propertiesInitialValue.IsEmpty())
                {
                    var propertiesInitialValueArray = propertiesInitialValue.ToArray();
                    copyMethod = eventTypeSPI.GetCopyMethod(propertiesInitialValueArray);
                }
            }

            var updateItemsArray = updateItems.ToArray();

            return(new EventBeanUpdateHelper(copyMethod, updateItemsArray));
        }
예제 #24
0
        private void RunAssertionColDefPlain(EventRepresentationChoice eventRepresentationEnum)
        {
            EPStatement stmtCreate = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col1 string, col2 int, col3_col4 int)");

            AssertTypeColDef(stmtCreate.EventType);
            EPStatement stmtSelect = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select * from MyEventType");

            AssertTypeColDef(stmtSelect.EventType);

            stmtSelect.Dispose();
            stmtCreate.Dispose();

            // destroy and create differently
            stmtCreate = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col3 string, col4 int)");
            Assert.AreEqual(typeof(int?), TypeHelper.GetBoxedType(stmtCreate.EventType.GetPropertyType("col4")));
            Assert.AreEqual(2, stmtCreate.EventType.PropertyDescriptors.Count);

            stmtCreate.Stop();

            // destroy and create differently
            stmtCreate = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col5 string, col6 int)");
            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtCreate.EventType.UnderlyingType));
            Assert.AreEqual(typeof(int?), TypeHelper.GetBoxedType(stmtCreate.EventType.GetPropertyType("col6")));
            Assert.AreEqual(2, stmtCreate.EventType.PropertyDescriptors.Count);
            stmtSelect = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select * from MyEventType");
            stmtSelect.AddListener(listener);
            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtSelect.EventType.UnderlyingType));

            // send event
            if (eventRepresentationEnum.IsMapEvent())
            {
                var data = new LinkedHashMap <string, Object>();
                data.Put("col5", "abc");
                data.Put("col6", 1);
                epService.EPRuntime.SendEvent(data, "MyEventType");
            }
            else if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                epService.EPRuntime.SendEvent(new Object[] { "abc", 1 }, "MyEventType");
            }
            else if (eventRepresentationEnum.IsAvroEvent())
            {
                RecordSchema  schema = (RecordSchema)((AvroSchemaEventType)epService.EPAdministrator.Configuration.GetEventType("MyEventType")).Schema;
                GenericRecord @event = new GenericRecord(schema);
                @event.Put("col5", "abc");
                @event.Put("col6", 1);
                epService.EPRuntime.SendEventAvro(@event, "MyEventType");
            }
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "col5,col6".SplitCsv(), new Object[] { "abc", 1 });

            // assert type information
            EventTypeSPI typeSPI = (EventTypeSPI)stmtSelect.EventType;

            Assert.AreEqual(TypeClass.APPLICATION, typeSPI.Metadata.TypeClass);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PublicName);
            Assert.IsTrue(typeSPI.Metadata.IsApplicationConfigured);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfigured);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfiguredStatic);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PrimaryName);

            // test non-enum create-schema
            string      epl           = "create" + eventRepresentationEnum.GetOutputTypeCreateSchemaName() + " schema MyEventTypeTwo as (col1 string, col2 int, col3_col4 int)";
            EPStatement stmtCreateTwo = epService.EPAdministrator.CreateEPL(epl);

            AssertTypeColDef(stmtCreateTwo.EventType);
            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtCreateTwo.EventType.UnderlyingType));
            stmtCreateTwo.Dispose();
            epService.EPAdministrator.Configuration.RemoveEventType("MyEventTypeTwo", true);

            EPStatementObjectModel model = epService.EPAdministrator.CompileEPL(epl);

            Assert.AreEqual(model.ToEPL(), epl);
            stmtCreateTwo = epService.EPAdministrator.Create(model);
            AssertTypeColDef(stmtCreateTwo.EventType);
            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtCreateTwo.EventType.UnderlyingType));

            epService.Initialize();
        }
        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));
        }
예제 #26
0
        private NamedWindowOnMergeActionIns SetupInsert(
            string namedWindowName,
            InternalEventRouter internalEventRouter,
            EventTypeSPI eventTypeNamedWindow,
            int selectClauseNumber,
            OnTriggerMergeActionInsert desc,
            EventType triggeringEventType,
            string triggeringStreamName,
            StatementContext statementContext)
        {
            // Compile insert-into info
            var streamName     = desc.OptionalStreamName ?? eventTypeNamedWindow.Name;
            var insertIntoDesc = InsertIntoDesc.FromColumns(streamName, desc.Columns);

            // rewrite any wildcards to use "stream.wildcard"
            if (triggeringStreamName == null)
            {
                triggeringStreamName = UuidGenerator.Generate();
            }
            var selectNoWildcard = CompileSelectNoWildcard(triggeringStreamName, desc.SelectClauseCompiled);

            // Set up event types for select-clause evaluation: The first type does not contain anything as its the named window row which is not present for insert
            EventType         dummyTypeNoProperties = new MapEventType(EventTypeMetadata.CreateAnonymous("merge_named_window_insert"), "merge_named_window_insert", 0, null, Collections.GetEmptyMap <string, object>(), null, null, null);
            var               eventTypes            = new EventType[] { dummyTypeNoProperties, triggeringEventType };
            var               streamNames           = new string[] { UuidGenerator.Generate(), triggeringStreamName };
            StreamTypeService streamTypeService     = new StreamTypeServiceImpl(eventTypes, streamNames, new bool[1], statementContext.EngineURI, false);

            // Get select expr processor
            var selectExprEventTypeRegistry = new SelectExprEventTypeRegistry(statementContext.StatementName, statementContext.StatementEventTypeRef);
            var exprEvaluatorContext        = new ExprEvaluatorContextStatement(statementContext, false);
            var insertHelper = SelectExprProcessorFactory.GetProcessor(
                Collections.SingletonSet <int>(selectClauseNumber),
                selectNoWildcard.ToArray(), false, insertIntoDesc, null, null, streamTypeService,
                statementContext.EventAdapterService,
                statementContext.StatementResultService,
                statementContext.ValueAddEventService,
                selectExprEventTypeRegistry,
                statementContext.MethodResolutionService,
                exprEvaluatorContext,
                statementContext.VariableService,
                statementContext.ScriptingService,
                statementContext.TableService,
                statementContext.TimeProvider,
                statementContext.EngineURI,
                statementContext.StatementId,
                statementContext.StatementName,
                statementContext.Annotations,
                statementContext.ContextDescriptor,
                statementContext.ConfigSnapshot, null,
                statementContext.NamedWindowService, null);
            var filterEval = desc.OptionalWhereClause == null ? null : desc.OptionalWhereClause.ExprEvaluator;

            var routerToUser = streamName.Equals(namedWindowName) ? null : internalEventRouter;
            var audit        = AuditEnum.INSERT.GetAudit(statementContext.Annotations) != null;

            string insertIntoTableName = null;

            if (statementContext.TableService.GetTableMetadata(insertIntoDesc.EventTypeName) != null)
            {
                insertIntoTableName = insertIntoDesc.EventTypeName;
            }

            return(new NamedWindowOnMergeActionIns(filterEval, insertHelper, routerToUser, insertIntoTableName, statementContext.TableService, statementContext.EpStatementHandle, statementContext.InternalEventEngineRouteDest, audit));
        }
예제 #27
0
        public NamedWindowOnMergeHelper(StatementContext statementContext,
                                        OnTriggerMergeDesc onTriggerDesc,
                                        EventType triggeringEventType,
                                        string triggeringStreamName,
                                        InternalEventRouter internalEventRouter,
                                        string namedWindowName,
                                        EventTypeSPI namedWindowType)

        {
            Matched   = new List <NamedWindowOnMergeMatch>();
            Unmatched = new List <NamedWindowOnMergeMatch>();

            var count = 1;

            foreach (var matchedItem in onTriggerDesc.Items)
            {
                IList <NamedWindowOnMergeAction> actions = new List <NamedWindowOnMergeAction>();
                foreach (var item in matchedItem.Actions)
                {
                    try {
                        if (item is OnTriggerMergeActionInsert)
                        {
                            var insertDesc = (OnTriggerMergeActionInsert)item;
                            actions.Add(SetupInsert(namedWindowName, internalEventRouter, namedWindowType, count, insertDesc, triggeringEventType, triggeringStreamName, statementContext));
                        }
                        else if (item is OnTriggerMergeActionUpdate)
                        {
                            var updateDesc   = (OnTriggerMergeActionUpdate)item;
                            var updateHelper = EventBeanUpdateHelperFactory.Make(namedWindowName, namedWindowType, updateDesc.Assignments, onTriggerDesc.OptionalAsName, triggeringEventType, true);
                            var filterEval   = updateDesc.OptionalWhereClause == null ? null : updateDesc.OptionalWhereClause.ExprEvaluator;
                            actions.Add(new NamedWindowOnMergeActionUpd(filterEval, updateHelper));
                        }
                        else if (item is OnTriggerMergeActionDelete)
                        {
                            var deleteDesc = (OnTriggerMergeActionDelete)item;
                            var filterEval = deleteDesc.OptionalWhereClause == null ? null : deleteDesc.OptionalWhereClause.ExprEvaluator;
                            actions.Add(new NamedWindowOnMergeActionDel(filterEval));
                        }
                        else
                        {
                            throw new ArgumentException("Invalid type of merge item '" + item.GetType() + "'");
                        }
                        count++;
                    }
                    catch (ExprValidationException ex) {
                        var isNot   = item is OnTriggerMergeActionInsert;
                        var message = "Validation failed in when-" + (isNot?"not-":"") + "matched (clause " + count + "): " + ex.Message;
                        throw new ExprValidationException(message, ex);
                    }
                }

                if (matchedItem.IsMatchedUnmatched)
                {
                    Matched.Add(new NamedWindowOnMergeMatch(matchedItem.OptionalMatchCond, actions));
                }
                else
                {
                    Unmatched.Add(new NamedWindowOnMergeMatch(matchedItem.OptionalMatchCond, actions));
                }
            }
        }
        public override void Run(EPServiceProvider epService)
        {
            var legacyDef = new ConfigurationEventTypeLegacy();

            legacyDef.AccessorStyle  = AccessorStyleEnum.PUBLIC;
            legacyDef.CodeGeneration = _codegen ? CodeGenerationEnum.ENABLED : CodeGenerationEnum.DISABLED;
            legacyDef.AddFieldProperty("explicitFSimple", "fieldLegacyVal");
            legacyDef.AddFieldProperty("explicitFIndexed", "fieldStringArray");
            legacyDef.AddFieldProperty("explicitFNested", "fieldNested");
            legacyDef.AddMethodProperty("explicitMSimple", "ReadLegacyBeanVal");
            legacyDef.AddMethodProperty("explicitMArray", "ReadStringArray");
            legacyDef.AddMethodProperty("explicitMIndexed", "ReadStringIndexed");
            legacyDef.AddMethodProperty("explicitMMapped", "ReadMapByKey");
            epService.EPAdministrator.Configuration.AddEventType <SupportLegacyBean>("MyLegacyEvent", legacyDef);

            legacyDef = new ConfigurationEventTypeLegacy();
            legacyDef.AccessorStyle  = AccessorStyleEnum.PUBLIC;
            legacyDef.CodeGeneration = CodeGenerationEnum.DISABLED;
            epService.EPAdministrator.Configuration.AddEventType <SupportLegacyBean.LegacyNested>("MyLegacyNestedEvent", legacyDef);

            // assert type metadata
            EventTypeSPI type = (EventTypeSPI)((EPServiceProviderSPI)epService).EventAdapterService.GetEventTypeByName("MyLegacyEvent");

            Assert.AreEqual(ApplicationType.CLASS, type.Metadata.OptionalApplicationType);
            Assert.AreEqual(1, type.Metadata.OptionalSecondaryNames.Count);
            Assert.AreEqual(typeof(SupportLegacyBean).Name, type.Metadata.OptionalSecondaryNames.First());
            Assert.AreEqual("MyLegacyEvent", type.Metadata.PrimaryName);
            Assert.AreEqual("MyLegacyEvent", type.Metadata.PublicName);
            Assert.AreEqual(TypeClass.APPLICATION, type.Metadata.TypeClass);
            Assert.AreEqual(true, type.Metadata.IsApplicationConfigured);
            Assert.AreEqual(false, type.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(false, type.Metadata.IsApplicationPreConfiguredStatic);

            string statementText = "select " +
                                   "fieldLegacyVal as fieldSimple," +
                                   "fieldStringArray as fieldArr," +
                                   "fieldStringArray[1] as fieldArrIndexed," +
                                   "fieldMapped as fieldMap," +
                                   "fieldNested as fieldNested," +
                                   "fieldNested.ReadNestedValue as fieldNestedVal," +
                                   "ReadLegacyBeanVal as simple," +
                                   "ReadLegacyNested as nestedObject," +
                                   "ReadLegacyNested.ReadNestedValue as nested," +
                                   "ReadStringArray[0] as array," +
                                   "ReadStringIndexed[1] as indexed," +
                                   "ReadMapByKey('key1') as mapped," +
                                   "ReadMap as mapItself," +
                                   "explicitFSimple, " +
                                   "explicitFIndexed[0], " +
                                   "explicitFNested, " +
                                   "explicitMSimple, " +
                                   "explicitMArray[0], " +
                                   "explicitMIndexed[1], " +
                                   "explicitMMapped('key2')" +
                                   " from MyLegacyEvent#length(5)";

            EPStatement statement = epService.EPAdministrator.CreateEPL(statementText);
            var         listener  = new SupportUpdateListener();

            statement.Events += listener.Update;

            EventType eventType = statement.EventType;

            Assert.AreEqual(typeof(string), eventType.GetPropertyType("fieldSimple"));
            Assert.AreEqual(typeof(string[]), eventType.GetPropertyType("fieldArr"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("fieldArrIndexed"));
            Assert.AreEqual(typeof(IDictionary <string, string>), eventType.GetPropertyType("fieldMap"));
            Assert.AreEqual(typeof(SupportLegacyBean.LegacyNested), eventType.GetPropertyType("fieldNested"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("fieldNestedVal"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("simple"));
            Assert.AreEqual(typeof(SupportLegacyBean.LegacyNested), eventType.GetPropertyType("nestedObject"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("nested"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("array"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("indexed"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("mapped"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("explicitFSimple"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("explicitFIndexed[0]"));
            Assert.AreEqual(typeof(SupportLegacyBean.LegacyNested), eventType.GetPropertyType("explicitFNested"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("explicitMSimple"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("explicitMArray[0]"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("explicitMIndexed[1]"));
            Assert.AreEqual(typeof(string), eventType.GetPropertyType("explicitMMapped('key2')"));

            SupportLegacyBean legacyBean = MakeSampleEvent();

            epService.EPRuntime.SendEvent(legacyBean);

            Assert.AreEqual(legacyBean.fieldLegacyVal, listener.LastNewData[0].Get("fieldSimple"));
            Assert.AreEqual(legacyBean.fieldStringArray, listener.LastNewData[0].Get("fieldArr"));
            Assert.AreEqual(legacyBean.fieldStringArray[1], listener.LastNewData[0].Get("fieldArrIndexed"));
            Assert.AreEqual(legacyBean.fieldMapped, listener.LastNewData[0].Get("fieldMap"));
            Assert.AreEqual(legacyBean.fieldNested, listener.LastNewData[0].Get("fieldNested"));
            Assert.AreEqual(legacyBean.fieldNested.ReadNestedValue(), listener.LastNewData[0].Get("fieldNestedVal"));

            Assert.AreEqual(legacyBean.ReadLegacyBeanVal(), listener.LastNewData[0].Get("simple"));
            Assert.AreEqual(legacyBean.ReadLegacyNested(), listener.LastNewData[0].Get("nestedObject"));
            Assert.AreEqual(legacyBean.ReadLegacyNested().ReadNestedValue(), listener.LastNewData[0].Get("nested"));
            Assert.AreEqual(legacyBean.ReadStringIndexed(0), listener.LastNewData[0].Get("array"));
            Assert.AreEqual(legacyBean.ReadStringIndexed(1), listener.LastNewData[0].Get("indexed"));
            Assert.AreEqual(legacyBean.ReadMapByKey("key1"), listener.LastNewData[0].Get("mapped"));
            Assert.AreEqual(legacyBean.ReadMap(), listener.LastNewData[0].Get("mapItself"));

            Assert.AreEqual(legacyBean.ReadLegacyBeanVal(), listener.LastNewData[0].Get("explicitFSimple"));
            Assert.AreEqual(legacyBean.ReadLegacyBeanVal(), listener.LastNewData[0].Get("explicitMSimple"));
            Assert.AreEqual(legacyBean.ReadLegacyNested(), listener.LastNewData[0].Get("explicitFNested"));
            Assert.AreEqual(legacyBean.ReadStringIndexed(0), listener.LastNewData[0].Get("explicitFIndexed[0]"));
            Assert.AreEqual(legacyBean.ReadStringIndexed(0), listener.LastNewData[0].Get("explicitMArray[0]"));
            Assert.AreEqual(legacyBean.ReadStringIndexed(1), listener.LastNewData[0].Get("explicitMIndexed[1]"));
            Assert.AreEqual(legacyBean.ReadMapByKey("key2"), listener.LastNewData[0].Get("explicitMMapped('key2')"));

            EventTypeSPI stmtType = (EventTypeSPI)statement.EventType;

            Assert.AreEqual(ApplicationType.MAP, stmtType.Metadata.OptionalApplicationType);
            Assert.AreEqual(null, stmtType.Metadata.OptionalSecondaryNames);
            Assert.IsNotNull(stmtType.Metadata.PrimaryName);
            Assert.IsNotNull(stmtType.Metadata.PublicName);
            Assert.IsNotNull(stmtType.Name);
            Assert.AreEqual(TypeClass.ANONYMOUS, stmtType.Metadata.TypeClass);
            Assert.AreEqual(false, stmtType.Metadata.IsApplicationConfigured);
            Assert.AreEqual(false, stmtType.Metadata.IsApplicationPreConfigured);
            Assert.AreEqual(false, stmtType.Metadata.IsApplicationPreConfiguredStatic);
        }
예제 #29
0
        public InfraOnMergeHelperForge(
            OnTriggerMergeDesc onTriggerDesc,
            EventType triggeringEventType,
            string triggeringStreamName,
            string infraName,
            EventTypeSPI infraEventType,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices services,
            TableMetaData table)
        {
            matched = new List<InfraOnMergeMatchForge>();
            unmatched = new List<InfraOnMergeMatchForge>();

            var count = 1;
            var hasDeleteAction = false;
            var hasInsertIntoTableAction = false;
            var hasUpdateAction = false;

            foreach (var matchedItem in onTriggerDesc.Items) {
                IList<InfraOnMergeActionForge> actions = new List<InfraOnMergeActionForge>();
                foreach (OnTriggerMergeAction item in matchedItem.Actions) {
                    try {
                        if (item is OnTriggerMergeActionInsert) {
                            var insertDesc = (OnTriggerMergeActionInsert) item;
                            var forge = SetupInsert(
                                infraName,
                                infraEventType,
                                insertDesc,
                                triggeringEventType,
                                triggeringStreamName,
                                statementRawInfo,
                                services,
                                table != null);
                            actions.Add(forge);
                            hasInsertIntoTableAction = forge.InsertIntoTable != null;
                        }
                        else if (item is OnTriggerMergeActionUpdate) {
                            var updateDesc = (OnTriggerMergeActionUpdate) item;
                            EventBeanUpdateHelperForge updateHelper = EventBeanUpdateHelperForgeFactory.Make(
                                infraName,
                                infraEventType,
                                updateDesc.Assignments,
                                onTriggerDesc.OptionalAsName,
                                triggeringEventType,
                                true,
                                statementRawInfo.StatementName,
                                services.EventTypeAvroHandler);
                            ExprNode filterEval = updateDesc.OptionalWhereClause;
                            if (table != null) {
                                TableUpdateStrategyFactory.ValidateTableUpdateOnMerge(
                                    table,
                                    updateHelper.UpdateItemsPropertyNames);
                            }

                            var forge = new InfraOnMergeActionUpdForge(filterEval, updateHelper, table);
                            actions.Add(forge);
                            hasUpdateAction = true;
                        }
                        else if (item is OnTriggerMergeActionDelete) {
                            var deleteDesc = (OnTriggerMergeActionDelete) item;
                            ExprNode filterEval = deleteDesc.OptionalWhereClause;
                            actions.Add(new InfraOnMergeActionDelForge(filterEval));
                            hasDeleteAction = true;
                        }
                        else {
                            throw new ArgumentException("Invalid type of merge item '" + item.GetType() + "'");
                        }

                        count++;
                    }
                    catch (Exception ex) when (ex is ExprValidationException || ex is EPException) {
                        var isNot = item is OnTriggerMergeActionInsert;
                        var message = "Validation failed in when-" +
                                      (isNot ? "not-" : "") +
                                      "matched (clause " +
                                      count +
                                      "): " +
                                      ex.Message;
                        throw new ExprValidationException(message, ex);
                    }
                }

                if (matchedItem.IsMatchedUnmatched) {
                    matched.Add(new InfraOnMergeMatchForge(matchedItem.OptionalMatchCond, actions));
                }
                else {
                    unmatched.Add(new InfraOnMergeMatchForge(matchedItem.OptionalMatchCond, actions));
                }
            }

            if (onTriggerDesc.OptionalInsertNoMatch != null) {
                insertUnmatched = SetupInsert(
                    infraName,
                    infraEventType,
                    onTriggerDesc.OptionalInsertNoMatch,
                    triggeringEventType,
                    triggeringStreamName,
                    statementRawInfo,
                    services,
                    table != null);
            }

            requiresTableWriteLock = hasDeleteAction || hasInsertIntoTableAction || hasUpdateAction;
        }
예제 #30
0
        private void RunAssertionColDefPlain(EventRepresentationEnum eventRepresentationEnum)
        {
            EPStatement stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col1 string, col2 int, sbean " + typeof(SupportBean).FullName + ", col3.col4 int)");

            AssertTypeColDef(stmtCreate.EventType);
            EPStatement stmtSelect = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select * from MyEventType");

            AssertTypeColDef(stmtSelect.EventType);

            stmtSelect.Dispose();
            stmtCreate.Dispose();

            // destroy and create differently
            stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col3 string, col4 int)");
            Assert.AreEqual(typeof(int), stmtCreate.EventType.GetPropertyType("col4"));
            Assert.AreEqual(2, stmtCreate.EventType.PropertyDescriptors.Count);

            stmtCreate.Stop();

            // destroy and create differently
            stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col5 string, col6 int)");
            Assert.AreEqual(stmtCreate.EventType.UnderlyingType, eventRepresentationEnum.GetOutputClass());
            Assert.AreEqual(typeof(int), stmtCreate.EventType.GetPropertyType("col6"));
            Assert.AreEqual(2, stmtCreate.EventType.PropertyDescriptors.Count);
            stmtSelect         = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select * from MyEventType");
            stmtSelect.Events += _listener.Update;
            Assert.AreEqual(stmtSelect.EventType.UnderlyingType, eventRepresentationEnum.GetOutputClass());

            // send event
            IDictionary <String, Object> data = new LinkedHashMap <String, Object>();

            data.Put("col5", "abc");
            data.Put("col6", 1);
            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                _epService.EPRuntime.SendEvent(data.Values.ToArray(), "MyEventType");
            }
            else
            {
                _epService.EPRuntime.SendEvent(data, "MyEventType");
            }
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "col5,col6".Split(','), new Object[] { "abc", 1 });

            // assert type information
            EventTypeSPI typeSPI = (EventTypeSPI)stmtSelect.EventType;

            Assert.AreEqual(TypeClass.APPLICATION, typeSPI.Metadata.TypeClass);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PublicName);
            Assert.IsTrue(typeSPI.Metadata.IsApplicationConfigured);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfigured);
            Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfiguredStatic);
            Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PrimaryName);

            // test non-enum create-schema
            String      epl           = "create" + eventRepresentationEnum.GetOutputTypeCreateSchemaName() + " schema MyEventTypeTwo as (col1 string, col2 int, sbean " + typeof(SupportBean).FullName + ", col3.col4 int)";
            EPStatement stmtCreateTwo = _epService.EPAdministrator.CreateEPL(epl);

            AssertTypeColDef(stmtCreateTwo.EventType);
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreateTwo.EventType.UnderlyingType);
            stmtCreateTwo.Dispose();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyEventTypeTwo", true);

            EPStatementObjectModel model = _epService.EPAdministrator.CompileEPL(epl);

            Assert.AreEqual(model.ToEPL(), epl);
            stmtCreateTwo = _epService.EPAdministrator.Create(model);
            AssertTypeColDef(stmtCreateTwo.EventType);
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreateTwo.EventType.UnderlyingType);

            _epService.Initialize();
        }