Exemplo n.º 1
0
        public void TestGetValueTopComplex()
        {
            String stmtText = "select item?.Indexed[0] as Indexed1, " +
                              "item?.Indexed[1]? as Indexed2, " +
                              "item?.ArrayProperty[1]? as Array, " +
                              "item?.Mapped('keyOne') as Mapped1, " +
                              "item?.Mapped('keyTwo')? as Mapped2,  " +
                              "item?.MapProperty('xOne')? as map " +
                              "from " + typeof(SupportBeanDynRoot).FullName;
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);
            stmt.Events += _listener.Update;

            Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Indexed1"));
            Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Indexed2"));
            Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Mapped1"));
            Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Mapped2"));
            Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Array"));

            SupportBeanComplexProps inner = SupportBeanComplexProps.MakeDefaultBean();
            _epService.EPRuntime.SendEvent(new SupportBeanDynRoot(inner));
            EventBean theEvent = _listener.AssertOneGetNewAndReset();
            Assert.AreEqual(inner.GetIndexed(0), theEvent.Get("Indexed1"));
            Assert.AreEqual(inner.GetIndexed(1), theEvent.Get("Indexed2"));
            Assert.AreEqual(inner.GetMapped("keyOne"), theEvent.Get("Mapped1"));
            Assert.AreEqual(inner.GetMapped("keyTwo"), theEvent.Get("Mapped2"));
            Assert.AreEqual(inner.MapProperty.Get("xOne"), theEvent.Get("map"));
            Assert.AreEqual(inner.ArrayProperty[1], theEvent.Get("Array"));
        }
Exemplo n.º 2
0
        public void TestWhereAndSelect()
        {
            String viewExpr = "select Mapped('keyOne') as a," +
                              "Indexed[1] as b, Nested.NestedNested.NestedNestedValue as c, MapProperty, " +
                              "ArrayProperty[0] " +
                              "  from " + typeof(SupportBeanComplexProps).FullName + "#length(3) " +
                              " where Mapped('keyOne') = 'valueOne' and " +
                              " Indexed[1] = 2 and " +
                              " Nested.NestedNested.NestedNestedValue = 'NestedNestedValue'";

            EPStatement testView = epService.EPAdministrator.CreateEPL(viewExpr);

            testListener     = new SupportUpdateListener();
            testView.Events += testListener.Update;

            SupportBeanComplexProps eventObject = SupportBeanComplexProps.MakeDefaultBean();

            epService.EPRuntime.SendEvent(eventObject);
            EventBean theEvent = testListener.GetAndResetLastNewData()[0];

            Assert.AreEqual(eventObject.GetMapped("keyOne"), theEvent.Get("a"));
            Assert.AreEqual(eventObject.GetIndexed(1), theEvent.Get("b"));
            Assert.AreEqual(eventObject.Nested.NestedNested.NestedNestedValue, theEvent.Get("c"));
            Assert.AreEqual(eventObject.MapProperty, theEvent.Get("MapProperty"));
            Assert.AreEqual(eventObject.ArrayProperty[0], theEvent.Get("ArrayProperty[0]"));

            eventObject.SetIndexed(1, int.MinValue);
            Assert.IsFalse(testListener.IsInvoked);
            epService.EPRuntime.SendEvent(eventObject);
            Assert.IsFalse(testListener.IsInvoked);

            eventObject.SetIndexed(1, 2);
            epService.EPRuntime.SendEvent(eventObject);
            Assert.IsTrue(testListener.IsInvoked);
        }
Exemplo n.º 3
0
        public void TestOuterJoin()
        {
            String viewExpr = "select * from " +
                              typeof(SupportBeanComplexProps).FullName + "#length(3) s0" +
                              " left outer join " +
                              typeof(SupportBeanCombinedProps).FullName + "#length(3) s1" +
                              " on Mapped('keyOne') = Indexed[2].Mapped('2ma').value";

            EPStatement testView = epService.EPAdministrator.CreateEPL(viewExpr);

            testListener     = new SupportUpdateListener();
            testView.Events += testListener.Update;

            SupportBeanCombinedProps combined = SupportBeanCombinedProps.MakeDefaultBean();

            epService.EPRuntime.SendEvent(combined);
            SupportBeanComplexProps complex = SupportBeanComplexProps.MakeDefaultBean();

            epService.EPRuntime.SendEvent(complex);

            // double check that outer join criteria match
            Assert.AreEqual(complex.GetMapped("keyOne"), combined.GetIndexed(2).GetMapped("2ma").Value);

            EventBean theEvent = testListener.GetAndResetLastNewData()[0];

            Assert.AreEqual("Simple", theEvent.Get("s0.SimpleProperty"));
            Assert.AreSame(complex, theEvent.Get("s0"));
            Assert.AreSame(combined, theEvent.Get("s1"));
        }
        public void TestPerformance()
        {
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }                                                                       // exclude test

            String stmtText = "select SimpleProperty?, " +
                              "Indexed[1]? as Indexed, " +
                              "Mapped('keyOne')? as Mapped " +
                              "from " + typeof(SupportBeanComplexProps).FullName;
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.Events += _listener.Update;

            EventType type = stmt.EventType;

            Assert.AreEqual(typeof(Object), type.GetPropertyType("SimpleProperty?"));
            Assert.AreEqual(typeof(Object), type.GetPropertyType("Indexed"));
            Assert.AreEqual(typeof(Object), type.GetPropertyType("Mapped"));

            SupportBeanComplexProps inner = SupportBeanComplexProps.MakeDefaultBean();

            _epService.EPRuntime.SendEvent(inner);
            EventBean theEvent = _listener.AssertOneGetNewAndReset();

            Assert.AreEqual(inner.SimpleProperty, theEvent.Get("SimpleProperty?"));
            Assert.AreEqual(inner.GetIndexed(1), theEvent.Get("Indexed"));
            Assert.AreEqual(inner.GetMapped("keyOne"), theEvent.Get("Mapped"));

            long start = PerformanceObserver.MilliTime;

            for (int i = 0; i < 10000; i++)
            {
                _epService.EPRuntime.SendEvent(inner);
                if (i % 1000 == 0)
                {
                    _listener.Reset();
                }
            }
            long end   = PerformanceObserver.MilliTime;
            long delta = end - start;

            Assert.IsTrue(delta < 1000, "delta=" + delta);
        }
Exemplo n.º 5
0
        public override void Run(EPServiceProvider epService)
        {
            string stmtText = "select simpleProperty?, " +
                              "indexed[1]? as indexed, " +
                              "Mapped('keyOne')? as mapped " +
                              "from " + typeof(SupportBeanComplexProps).FullName;
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(stmtText);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            EventType type = stmt.EventType;

            Assert.AreEqual(typeof(Object), type.GetPropertyType("simpleProperty?"));
            Assert.AreEqual(typeof(Object), type.GetPropertyType("indexed"));
            Assert.AreEqual(typeof(Object), type.GetPropertyType("mapped"));

            SupportBeanComplexProps inner = SupportBeanComplexProps.MakeDefaultBean();

            epService.EPRuntime.SendEvent(inner);
            EventBean theEvent = listener.AssertOneGetNewAndReset();

            Assert.AreEqual(inner.SimpleProperty, theEvent.Get("simpleProperty?"));
            Assert.AreEqual(inner.GetIndexed(1), theEvent.Get("indexed"));
            Assert.AreEqual(inner.GetMapped("keyOne"), theEvent.Get("mapped"));

            long start = PerformanceObserver.MilliTime;

            for (int i = 0; i < 10000; i++)
            {
                epService.EPRuntime.SendEvent(inner);
                if (i % 1000 == 0)
                {
                    listener.Reset();
                }
            }
            long end   = PerformanceObserver.MilliTime;
            long delta = end - start;

            Assert.IsTrue(delta < 1000, "delta=" + delta);
        }
        public void TestIt()
        {
            ValueWithExistsFlag[] NOT_EXISTS = ValueWithExistsFlag.MultipleNotExists(4);

            // Bean
            SupportBeanComplexProps bean = SupportBeanComplexProps.MakeDefaultBean();
            var beanTests = new Pair <SupportBeanComplexProps, ValueWithExistsFlag[]>[] {
                new Pair <SupportBeanComplexProps, ValueWithExistsFlag[]>(bean, ValueWithExistsFlag.AllExist(bean.GetIndexed(0), bean.GetIndexed(1), bean.GetMapped("keyOne"), bean.GetMapped("keyTwo")))
            };

            RunAssertion(BEAN_TYPE.Name, SupportEventInfra.FBEAN, null, beanTests, typeof(object));

            // Map
            var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>[] {
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(Collections.SingletonDataMap("somekey", "10"), NOT_EXISTS),
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(SupportEventInfra.TwoEntryMap("indexed", new int[] { 1, 2 }, "mapped", SupportEventInfra.TwoEntryMap("keyOne", 3, "keyTwo", 4)), ValueWithExistsFlag.AllExist(1, 2, 3, 4)),
            };

            RunAssertion(SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object));

            // Object-Array
            var oaTests = new Pair <object[], ValueWithExistsFlag[]>[] {
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { null, null }, NOT_EXISTS),
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { new int[] { 1, 2 }, SupportEventInfra.TwoEntryMap("keyOne", 3, "keyTwo", 4) }, ValueWithExistsFlag.AllExist(1, 2, 3, 4)),
            };

            RunAssertion(SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object));

            // XML
            var xmlTests = new Pair <string, ValueWithExistsFlag[]>[] {
                new Pair <string, ValueWithExistsFlag[]>("", NOT_EXISTS),
                new Pair <string, ValueWithExistsFlag[]>("<indexed>1</indexed><indexed>2</indexed><mapped id=\"keyOne\">3</mapped><mapped id=\"keyTwo\">4</mapped>", ValueWithExistsFlag.AllExist("1", "2", "3", "4"))
            };

            RunAssertion(SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode));

            // Avro
            var datumOne = new GenericRecord(SchemaBuilder.Record(SupportEventInfra.AVRO_TYPENAME));
            var datumTwo = new GenericRecord(GetAvroSchema());

            datumTwo.Put("indexed", Collections.List(1, 2));
            datumTwo.Put("mapped", SupportEventInfra.TwoEntryMap("keyOne", 3, "keyTwo", 4));
            var avroTests = new Pair <GenericRecord, ValueWithExistsFlag[]>[] {
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumOne, NOT_EXISTS),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumTwo, ValueWithExistsFlag.AllExist(1, 2, 3, 4)),
            };

            RunAssertion(SupportEventInfra.AVRO_TYPENAME, SupportEventInfra.FAVRO, null, avroTests, typeof(object));
        }
Exemplo n.º 7
0
        public void TestIt()
        {
            var NOT_EXISTS = ValueWithExistsFlag.MultipleNotExists(6);

            // Bean
            SupportBeanComplexProps inner = SupportBeanComplexProps.MakeDefaultBean();
            var beanTests = new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>[] {
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot("xxx"), NOT_EXISTS),
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot(inner), ValueWithExistsFlag.AllExist(
                                                                         inner.GetIndexed(0),
                                                                         inner.GetIndexed(1),
                                                                         inner.ArrayProperty[1],
                                                                         inner.GetMapped("keyOne"),
                                                                         inner.GetMapped("keyTwo"),
                                                                         inner.MapProperty.Get("xOne"))),
            };

            RunAssertion(BEAN_TYPE.Name, SupportEventInfra.FBEAN, null, beanTests, typeof(object));

            // Map
            IDictionary <string, object> mapNestedOne = new Dictionary <string, object>();

            mapNestedOne.Put("indexed", new int[] { 1, 2 });
            mapNestedOne.Put("arrayProperty", null);
            mapNestedOne.Put("mapped", SupportEventInfra.TwoEntryMap("keyOne", 100, "keyTwo", 200));
            mapNestedOne.Put("mapProperty", null);
            var mapOne   = Collections.SingletonDataMap("item", mapNestedOne);
            var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>[] {
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(Collections.EmptyDataMap, NOT_EXISTS),
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(mapOne, new ValueWithExistsFlag[]
                {
                    ValueWithExistsFlag.Exists(1),
                    ValueWithExistsFlag.Exists(2),
                    ValueWithExistsFlag.NotExists(),
                    ValueWithExistsFlag.Exists(100),
                    ValueWithExistsFlag.Exists(200),
                    ValueWithExistsFlag.NotExists()
                }),
            };

            RunAssertion(SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object));

            // Object-Array
            var oaNestedOne = new object[] { new int[] { 1, 2 }, SupportEventInfra.TwoEntryMap("keyOne", 100, "keyTwo", 200), new int[] { 1000, 2000 }, Collections.SingletonMap("xOne", "abc") };
            var oaOne       = new object[] { null, oaNestedOne };
            var oaTests     = new Pair <object[], ValueWithExistsFlag[]>[] {
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { null, null }, NOT_EXISTS),
                new Pair <object[], ValueWithExistsFlag[]>(oaOne, ValueWithExistsFlag.AllExist(1, 2, 2000, 100, 200, "abc")),
            };

            RunAssertion(SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object));

            // XML
            var xmlTests = new Pair <string, ValueWithExistsFlag[]>[] {
                new Pair <string, ValueWithExistsFlag[]>("", NOT_EXISTS),
                new Pair <string, ValueWithExistsFlag[]>(
                    "<item>" +
                    "<indexed>1</indexed><indexed>2</indexed><mapped id=\"keyOne\">3</mapped><mapped id=\"keyTwo\">4</mapped>" +
                    "</item>", new ValueWithExistsFlag[]
                {
                    ValueWithExistsFlag.Exists("1"),
                    ValueWithExistsFlag.Exists("2"),
                    ValueWithExistsFlag.NotExists(),
                    ValueWithExistsFlag.Exists("3"),
                    ValueWithExistsFlag.Exists("4"),
                    ValueWithExistsFlag.NotExists()
                })
            };

            RunAssertion(SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode));

            // Avro
            var schema     = GetAvroSchema();
            var itemSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(schema.GetField("item").Schema).AsRecordSchema();
            var datumOne   = new GenericRecord(schema);

            datumOne.Put("item", null);
            var datumItemTwo = new GenericRecord(itemSchema);

            datumItemTwo.Put("indexed", Collections.List(1, 2));
            datumItemTwo.Put("mapped", SupportEventInfra.TwoEntryMap("keyOne", 3, "keyTwo", 4));
            var datumTwo = new GenericRecord(schema);

            datumTwo.Put("item", datumItemTwo);
            var avroTests = new Pair <GenericRecord, ValueWithExistsFlag[]>[] {
                new Pair <GenericRecord, ValueWithExistsFlag[]>(new GenericRecord(schema), NOT_EXISTS),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumOne, NOT_EXISTS),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumTwo, new ValueWithExistsFlag[]
                {
                    ValueWithExistsFlag.Exists(1),
                    ValueWithExistsFlag.Exists(2),
                    ValueWithExistsFlag.NotExists(),
                    ValueWithExistsFlag.Exists(3),
                    ValueWithExistsFlag.Exists(4),
                    ValueWithExistsFlag.NotExists()
                }),
            };

            RunAssertion(SupportEventInfra.AVRO_TYPENAME, SupportEventInfra.FAVRO, null, avroTests, typeof(object));
        }