示例#1
0
        private void RunAssertionTimeToLive(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));

            string[]    fields   = "id".Split(',');
            string      epl      = "select irstream * from SupportBeanTimestamp#timetolive(timestamp)";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SendEvent(epService, "E1", 1000);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } });

            SendEvent(epService, "E2", 500);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2" }, new object[] { "E1" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(499));
            Assert.IsFalse(listener.GetAndClearIsInvoked());

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(500));
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E2" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } });

            SendEvent(epService, "E3", 200);
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E3" }, new object[] { "E3" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" } });

            SendEvent(epService, "E4", 1200);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E4" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E4" } });

            SendEvent(epService, "E5", 1000);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E5" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1" }, new object[] { "E4" }, new object[] { "E5" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(999));
            Assert.IsFalse(listener.GetAndClearIsInvoked());

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(listener.GetAndResetDataListsFlattened(), fields, null, new object[][] { new object[] { "E1" }, new object[] { "E5" } });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E4" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1199));
            Assert.IsFalse(listener.GetAndClearIsInvoked());

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1200));
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E4" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendEvent(epService, "E6", 1200);
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E6" }, new object[] { "E6" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            epService.EPAdministrator.DestroyAllStatements();
        }
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>();

            var listenerInsert = new SupportUpdateListener();
            var listenerSelect = new SupportUpdateListener();

            string[] fields      = "c0,c1".Split(',');
            string   stmtTextOne = "insert irstream into MyStream " +
                                   "select irstream TheString as c0, istream() as c1 " +
                                   "from SupportBean#lastevent";

            epService.EPAdministrator.CreateEPL(stmtTextOne).Events += listenerInsert.Update;

            string stmtTextTwo = "select * from MyStream";

            epService.EPAdministrator.CreateEPL(stmtTextTwo).Events += listenerSelect.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 0));
            EPAssertionUtil.AssertProps(listenerInsert.AssertOneGetNewAndReset(), fields, new object[] { "E1", true });
            EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E1", true });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 0));
            EPAssertionUtil.AssertProps(listenerInsert.AssertPairGetIRAndReset(), fields, new object[] { "E2", true }, new object[] { "E1", false });
            EPAssertionUtil.AssertPropsPerRow(listenerSelect.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E2", true }, new object[] { "E1", false } }, new Object[0][]);

            epService.EPRuntime.SendEvent(new SupportBean("E3", 0));
            EPAssertionUtil.AssertProps(listenerInsert.AssertPairGetIRAndReset(), fields, new object[] { "E3", true }, new object[] { "E2", false });
            EPAssertionUtil.AssertPropsPerRow(listenerSelect.GetAndResetDataListsFlattened(), fields, new object[][] { new object[] { "E3", true }, new object[] { "E2", false } }, new Object[0][]);

            // test SODA
            string eplModel = "select istream() from SupportBean";
            EPStatementObjectModel model = epService.EPAdministrator.CompileEPL(eplModel);

            Assert.AreEqual(eplModel, model.ToEPL());
            EPStatement stmt = epService.EPAdministrator.Create(model);

            Assert.AreEqual(eplModel, stmt.Text);
            Assert.AreEqual(typeof(bool), stmt.EventType.GetPropertyType("istream()"));

            // test join
            epService.EPAdministrator.DestroyAllStatements();
            fields = "c0,c1,c2".Split(',');
            string stmtTextJoin = "select irstream TheString as c0, id as c1, istream() as c2 " +
                                  "from SupportBean#lastevent, SupportBean_S0#lastevent";

            epService.EPAdministrator.CreateEPL(stmtTextJoin).Events += listenerSelect.Update;
            epService.EPRuntime.SendEvent(new SupportBean("E1", 0));
            epService.EPRuntime.SendEvent(new SupportBean_S0(10));
            EPAssertionUtil.AssertProps(listenerSelect.AssertOneGetNewAndReset(), fields, new object[] { "E1", 10, true });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 0));
            EPAssertionUtil.AssertProps(listenerSelect.LastOldData[0], fields, new object[] { "E1", 10, false });
            EPAssertionUtil.AssertProps(listenerSelect.LastNewData[0], fields, new object[] { "E2", 10, true });
        }
示例#3
0
        private void RunAssertionRemoveStream(EPServiceProvider epService)
        {
            var fields     = "TheString,IntPrimitive,LongPrimitive".Split(',');
            var stmtCreate = epService.EPAdministrator.CreateEPL("create window MyWindow#rank(TheString, 3, IntPrimitive asc) as SupportBean");

            epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SupportBean");
            var stmtListen = epService.EPAdministrator.CreateEPL("select irstream * from MyWindow");
            var listener   = new SupportUpdateListener();

            stmtListen.Events += listener.Update;
            epService.EPAdministrator.CreateEPL("on SupportBean_A delete from MyWindow mw where TheString = id");

            epService.EPRuntime.SendEvent(MakeEvent("E1", 10, 0L));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 10, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 50, 0L));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2", 50, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10, 0L }, new object[] { "E2", 50, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E3", 5, 0L));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E3", 5, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 5, 0L }, new object[] { "E1", 10, 0L }, new object[] { "E2", 50, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E4", 5, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E4", 5, 0L }, new object[] { "E2", 50, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 5, 0L }, new object[] { "E4", 5, 0L }, new object[] { "E1", 10, 0L } });

            epService.EPRuntime.SendEvent(new SupportBean_A("E3"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E3", 5, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E4", 5, 0L }, new object[] { "E1", 10, 0L } });

            epService.EPRuntime.SendEvent(new SupportBean_A("E4"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E4", 5, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10, 0L } });

            epService.EPRuntime.SendEvent(new SupportBean_A("E1"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E1", 10, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[0][]);

            epService.EPRuntime.SendEvent(MakeEvent("E3", 100, 0L));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E3", 100, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 100, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E3", 101, 1L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E3", 101, 1L }, new object[] { "E3", 100, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E3", 101, 1L } });

            epService.EPRuntime.SendEvent(new SupportBean_A("E3"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E3", 101, 1L });
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new Object[0][]);

            epService.EPAdministrator.DestroyAllStatements();
        }
示例#4
0
        private void RunAssertionMultiexpression(EPServiceProvider epService)
        {
            var fields   = "TheString,IntPrimitive,LongPrimitive,DoublePrimitive".Split(',');
            var stmt     = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#rank(TheString, IntPrimitive, 3, LongPrimitive, DoublePrimitive)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(MakeEvent("E1", 100, 1L, 10d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 100, 1L, 10d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 100, 1L, 10d } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 200, 1L, 9d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 200, 1L, 9d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 200, 1L, 9d }, new object[] { "E1", 100, 1L, 10d } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 150, 1L, 11d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 150, 1L, 11d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 200, 1L, 9d }, new object[] { "E1", 100, 1L, 10d }, new object[] { "E1", 150, 1L, 11d } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 100, 1L, 8d));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E1", 100, 1L, 8d }, new object[] { "E1", 100, 1L, 10d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 100, 1L, 8d }, new object[] { "E1", 200, 1L, 9d }, new object[] { "E1", 150, 1L, 11d } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 300, 2L, 7d));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E2", 300, 2L, 7d }, new object[] { "E2", 300, 2L, 7d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 100, 1L, 8d }, new object[] { "E1", 200, 1L, 9d }, new object[] { "E1", 150, 1L, 11d } });

            epService.EPRuntime.SendEvent(MakeEvent("E3", 300, 1L, 8.5d));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E3", 300, 1L, 8.5d }, new object[] { "E1", 150, 1L, 11d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 100, 1L, 8d }, new object[] { "E3", 300, 1L, 8.5d }, new object[] { "E1", 200, 1L, 9d } });

            epService.EPRuntime.SendEvent(MakeEvent("E4", 400, 1L, 9d));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E4", 400, 1L, 9d }, new object[] { "E1", 200, 1L, 9d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 100, 1L, 8d }, new object[] { "E3", 300, 1L, 8.5d }, new object[] { "E4", 400, 1L, 9d } });

            stmt.Dispose();
        }
        private void RunAssertionMultiPropertyMapMixin(EPServiceProvider epService)
        {
            string[]    fields        = "K0,P1,P5,m0".Split(',');
            EPStatement stmtCreateWin = epService.EPAdministrator.CreateEPL
                                            ("create window RevMap#length(3) as select * from RevisableMap");

            epService.EPAdministrator.CreateEPL
                ("insert into RevMap select * from MyMap");
            epService.EPAdministrator.CreateEPL
                ("insert into RevMap select * from D1");
            epService.EPAdministrator.CreateEPL
                ("insert into RevMap select * from D5");

            EPStatement consumerOne = epService.EPAdministrator.CreateEPL
                                          ("select irstream * from RevMap order by K0");
            var listenerOne = new SupportUpdateListener();

            consumerOne.Events += listenerOne.Update;

            epService.EPRuntime.SendEvent(MakeMap(new object[][] { new object[] { "P5", "p5_1" }, new object[] { "P1", "p1_1" }, new object[] { "K0", "E1" }, new object[] { "m0", "M0" } }), "MyMap");
            EPAssertionUtil.AssertProps(listenerOne.AssertOneGetNewAndReset(), fields, new object[] { "E1", "p1_1", "p5_1", "M0" });

            epService.EPRuntime.SendEvent(new SupportDeltaFive("E2", "p1_1", "p5_1"));
            EPAssertionUtil.AssertProps(listenerOne.LastNewData[0], fields, new object[] { "E2", "p1_1", "p5_1", "M0" });
            EPAssertionUtil.AssertProps(listenerOne.LastOldData[0], fields, new object[] { "E1", "p1_1", "p5_1", "M0" });
            EPAssertionUtil.AssertProps(stmtCreateWin.First(), fields, new object[] { "E2", "p1_1", "p5_1", "M0" });
            listenerOne.Reset();

            epService.EPRuntime.SendEvent(MakeMap(new object[][] { new object[] { "P5", "p5_1" }, new object[] { "P1", "p1_2" }, new object[] { "K0", "E3" }, new object[] { "m0", "M1" } }), "MyMap");
            EPAssertionUtil.AssertPropsPerRow(stmtCreateWin.GetEnumerator(), fields, new object[][] { new object[] { "E2", "p1_1", "p5_1", "M0" }, new object[] { "E3", "p1_2", "p5_1", "M1" } });

            epService.EPRuntime.SendEvent(new SupportDeltaFive("E4", "p1_1", "p5_1"));
            EPAssertionUtil.AssertProps(listenerOne.LastNewData[0], fields, new object[] { "E4", "p1_1", "p5_1", "M0" });
            EPAssertionUtil.AssertProps(listenerOne.LastOldData[0], fields, new object[] { "E2", "p1_1", "p5_1", "M0" });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateWin.GetEnumerator(), fields, new object[][] { new object[] { "E3", "p1_2", "p5_1", "M1" }, new object[] { "E4", "p1_1", "p5_1", "M0" } });
            listenerOne.Reset();

            epService.EPRuntime.SendEvent(MakeMap(new object[][] { new object[] { "P5", "p5_2" }, new object[] { "P1", "p1_1" }, new object[] { "K0", "E5" }, new object[] { "m0", "M2" } }), "MyMap");
            EPAssertionUtil.AssertProps(listenerOne.AssertOneGetNewAndReset(), fields, new object[] { "E5", "p1_1", "p5_2", "M2" });
            EPAssertionUtil.AssertPropsPerRow(stmtCreateWin.GetEnumerator(), fields,
                                              new object[][] { new object[] { "E3", "p1_2", "p5_1", "M1" }, new object[] { "E4", "p1_1", "p5_1", "M0" }, new object[] { "E5", "p1_1", "p5_2", "M2" } });

            epService.EPRuntime.SendEvent(new SupportDeltaOne("E6", "p1_1", "p5_2"));
            EPAssertionUtil.AssertProps(listenerOne.AssertPairGetIRAndReset(), fields,
                                        new object[] { "E6", "p1_1", "p5_2", "M2" }, new object[] { "E5", "p1_1", "p5_2", "M2" });

            epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertionUpdateIStreamSetMapProps(
            EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum)
        {
            // test update-istream with map
            epService.EPAdministrator.CreateEPL(
                eventRepresentationEnum.GetAnnotationText() +
                " create schema MyInfraType(simple string, myarray int[], mymap Map)");
            var stmtUpdTwo = epService.EPAdministrator.CreateEPL(
                "update istream MyInfraType set simple='A', mymap('abc') = 1, myarray[2] = 10");
            var listener = new SupportUpdateListener();

            stmtUpdTwo.Events += listener.Update;

            if (eventRepresentationEnum.IsObjectArrayEvent())
            {
                epService.EPRuntime.SendEvent(
                    new object[] { null, new int[10], new Dictionary <string, object>() }, "MyInfraType");
            }
            else if (eventRepresentationEnum.IsMapEvent())
            {
                epService.EPRuntime.SendEvent(
                    MakeMapEvent(new Dictionary <string, object>(), new int[10]), "MyInfraType");
            }
            else if (eventRepresentationEnum.IsAvroEvent())
            {
                var @event = new GenericRecord(
                    SupportAvroUtil.GetAvroSchema(epService, "MyInfraType").AsRecordSchema());
                @event.Put("myarray", Collections.List(0, 0, 0, 0, 0));
                @event.Put("mymap", new Dictionary <string, object>());
                epService.EPRuntime.SendEventAvro(@event, "MyInfraType");
            }
            else
            {
                Assert.Fail();
            }

            EPAssertionUtil.AssertProps(
                listener.AssertPairGetIRAndReset(), "simple,mymap('abc'),myarray[2]".Split(','),
                new object[] { "A", 1, 10 }, new object[] { null, null, 0 });

            epService.EPAdministrator.DestroyAllStatements();
            foreach (var name in "MyInfraType".Split(','))
            {
                epService.EPAdministrator.Configuration.RemoveEventType(name, true);
            }
        }
        private void RunAssertionSetMapPropsBean(EPServiceProvider epService)
        {
            // test update-istream with bean
            epService.EPAdministrator.Configuration.AddEventType(typeof(MyMapPropEvent));
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            epService.EPAdministrator.CreateEPL("insert into MyStream select * from MyMapPropEvent");

            var stmtUpdOne =
                epService.EPAdministrator.CreateEPL("update istream MyStream set Props('abc') = 1, array[2] = 10");
            var listener = new SupportUpdateListener();

            stmtUpdOne.Events += listener.Update;

            epService.EPRuntime.SendEvent(new MyMapPropEvent());
            EPAssertionUtil.AssertProps(
                listener.AssertPairGetIRAndReset(), "Props('abc'),array[2]".Split(','), new object[] { 1, 10 },
                new object[] { null, null });
        }
        public void TestMultiPropertyMapMixin()
        {
            String[] fields = "K0,P1,P5,m0".Split(',');
            _stmtCreateWin =
                _epService.EPAdministrator.CreateEPL("create window RevMap.win:length(3) as select * from RevisableMap");
            _epService.EPAdministrator.CreateEPL("insert into RevMap select * from MyMap");
            _epService.EPAdministrator.CreateEPL("insert into RevMap select * from D1");
            _epService.EPAdministrator.CreateEPL("insert into RevMap select * from D5");

            EPStatement consumerOne = _epService.EPAdministrator.CreateEPL("select irstream * from RevMap order by K0");

            consumerOne.Events += _listenerOne.Update;

            _epService.EPRuntime.SendEvent(
                MakeMap(new Object[][]
            {
                new Object[] { "P5", "P5_1" }, new Object[] { "P1", "P1_1" }, new Object[] { "K0", "E1" },
                new Object[] { "m0", "M0" }
            }), "MyMap");
            EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), fields,
                                        new Object[] { "E1", "P1_1", "P5_1", "M0" });

            _epService.EPRuntime.SendEvent(new SupportDeltaFive("E2", "P1_1", "P5_1"));
            EPAssertionUtil.AssertProps(_listenerOne.LastNewData[0], fields,
                                        new Object[] { "E2", "P1_1", "P5_1", "M0" });
            EPAssertionUtil.AssertProps(_listenerOne.LastOldData[0], fields,
                                        new Object[] { "E1", "P1_1", "P5_1", "M0" });
            EPAssertionUtil.AssertProps(_stmtCreateWin.First(), fields, new Object[] { "E2", "P1_1", "P5_1", "M0" });
            _listenerOne.Reset();

            _epService.EPRuntime.SendEvent(
                MakeMap(new Object[][]
            {
                new Object[] { "P5", "P5_1" }, new Object[] { "P1", "P1_2" }, new Object[] { "K0", "E3" },
                new Object[] { "m0", "M1" }
            }), "MyMap");
            EPAssertionUtil.AssertPropsPerRow(_stmtCreateWin.GetEnumerator(), fields,
                                              new Object[][]
            {
                new Object[] { "E2", "P1_1", "P5_1", "M0" },
                new Object[] { "E3", "P1_2", "P5_1", "M1" }
            });

            _epService.EPRuntime.SendEvent(new SupportDeltaFive("E4", "P1_1", "P5_1"));
            EPAssertionUtil.AssertProps(_listenerOne.LastNewData[0], fields,
                                        new Object[] { "E4", "P1_1", "P5_1", "M0" });
            EPAssertionUtil.AssertProps(_listenerOne.LastOldData[0], fields,
                                        new Object[] { "E2", "P1_1", "P5_1", "M0" });
            EPAssertionUtil.AssertPropsPerRow(_stmtCreateWin.GetEnumerator(), fields,
                                              new Object[][]
            {
                new Object[] { "E3", "P1_2", "P5_1", "M1" },
                new Object[] { "E4", "P1_1", "P5_1", "M0" }
            });
            _listenerOne.Reset();

            _epService.EPRuntime.SendEvent(
                MakeMap(new Object[][]
            {
                new Object[] { "P5", "P5_2" }, new Object[] { "P1", "P1_1" }, new Object[] { "K0", "E5" },
                new Object[] { "m0", "M2" }
            }), "MyMap");
            EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), fields,
                                        new Object[] { "E5", "P1_1", "P5_2", "M2" });
            EPAssertionUtil.AssertPropsPerRow(_stmtCreateWin.GetEnumerator(), fields,
                                              new Object[][]
            {
                new Object[] { "E3", "P1_2", "P5_1", "M1" },
                new Object[] { "E4", "P1_1", "P5_1", "M0" },
                new Object[] { "E5", "P1_1", "P5_2", "M2" }
            });

            _epService.EPRuntime.SendEvent(new SupportDeltaOne("E6", "P1_1", "P5_2"));
            EPAssertionUtil.AssertProps(_listenerOne.AssertPairGetIRAndReset(), fields,
                                        new Object[] { "E6", "P1_1", "P5_2", "M2" },
                                        new Object[] { "E5", "P1_1", "P5_2", "M2" });
        }
示例#9
0
        public void TestPrevAndGroupWin()
        {
            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select prevwindow(ev) as win, prev(0, ev) as prev0, prev(1, ev) as prev1, prev(2, ev) as prev2, prev(3, ev) as prev3, prev(4, ev) as prev4 " +
                                                                    "from SupportBean#rank(TheString, 3, IntPrimitive) as ev");

            stmt.Events += _listener.Update;

            _epService.EPRuntime.SendEvent(MakeEvent("E1", 100, 0L));
            AssertWindowAggAndPrev(new Object[][]  { new Object[] { "E1", 100, 0L } });

            _epService.EPRuntime.SendEvent(MakeEvent("E2", 99, 0L));
            AssertWindowAggAndPrev(new Object[][]  { new Object[] { "E2", 99, 0L }, new Object[] { "E1", 100, 0L } });

            _epService.EPRuntime.SendEvent(MakeEvent("E1", 98, 1L));
            AssertWindowAggAndPrev(new Object[][]  { new Object[] { "E1", 98, 1L }, new Object[] { "E2", 99, 0L }, });

            _epService.EPRuntime.SendEvent(MakeEvent("E3", 98, 0L));
            AssertWindowAggAndPrev(new Object[][]  { new Object[] { "E1", 98, 1L }, new Object[] { "E3", 98, 0L }, new Object[] { "E2", 99, 0L } });

            _epService.EPRuntime.SendEvent(MakeEvent("E2", 97, 1L));
            AssertWindowAggAndPrev(new Object[][]  { new Object[] { "E2", 97, 1L }, new Object[] { "E1", 98, 1L }, new Object[] { "E3", 98, 0L } });
            stmt.Dispose();

            stmt         = _epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#groupwin(TheString)#rank(IntPrimitive, 2, DoublePrimitive) as ev");
            stmt.Events += _listener.Update;

            String[] fields = "TheString,IntPrimitive,LongPrimitive,DoublePrimitive".Split(',');
            _epService.EPRuntime.SendEvent(MakeEvent("E1", 100, 0L, 1d));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1", 100, 0L, 1d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new Object[][]  { new Object[] { "E1", 100, 0L, 1d } });

            _epService.EPRuntime.SendEvent(MakeEvent("E2", 100, 0L, 2d));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E2", 100, 0L, 2d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new Object[][]  { new Object[] { "E1", 100, 0L, 1d }, new Object[] { "E2", 100, 0L, 2d } });

            _epService.EPRuntime.SendEvent(MakeEvent("E1", 200, 0L, 0.5d));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1", 200, 0L, 0.5d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new Object[][]  { new Object[] { "E1", 200, 0L, 0.5d }, new Object[] { "E1", 100, 0L, 1d }, new Object[] { "E2", 100, 0L, 2d } });

            _epService.EPRuntime.SendEvent(MakeEvent("E2", 200, 0L, 2.5d));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E2", 200, 0L, 2.5d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new Object[][]  { new Object[] { "E1", 200, 0L, 0.5d }, new Object[] { "E1", 100, 0L, 1d }, new Object[] { "E2", 100, 0L, 2d }, new Object[] { "E2", 200, 0L, 2.5d } });

            _epService.EPRuntime.SendEvent(MakeEvent("E1", 300, 0L, 0.1d));
            EPAssertionUtil.AssertProps(_listener.AssertPairGetIRAndReset(), fields, new Object[] { "E1", 300, 0L, 0.1d }, new Object[] { "E1", 100, 0L, 1d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new Object[][]  { new Object[] { "E1", 300, 0L, 0.1d }, new Object[] { "E1", 200, 0L, 0.5d }, new Object[] { "E2", 100, 0L, 2d }, new Object[] { "E2", 200, 0L, 2.5d } });
        }
示例#10
0
        private void RunAssertionPrevAndGroupWin(EPServiceProvider epService)
        {
            var stmt = epService.EPAdministrator.CreateEPL("select prevwindow(ev) as win, prev(0, ev) as prev0, prev(1, ev) as prev1, prev(2, ev) as prev2, prev(3, ev) as prev3, prev(4, ev) as prev4 " +
                                                           "from SupportBean#rank(TheString, 3, IntPrimitive) as ev");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(MakeEvent("E1", 100, 0L));
            AssertWindowAggAndPrev(
                epService.Container, listener,
                new object[][] { new object[] { "E1", 100, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 99, 0L));
            AssertWindowAggAndPrev(
                epService.Container, listener,
                new object[][] { new object[] { "E2", 99, 0L }, new object[] { "E1", 100, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 98, 1L));
            AssertWindowAggAndPrev(
                epService.Container, listener,
                new object[][] { new object[] { "E1", 98, 1L }, new object[] { "E2", 99, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E3", 98, 0L));
            AssertWindowAggAndPrev(
                epService.Container, listener,
                new object[][] { new object[] { "E1", 98, 1L }, new object[] { "E3", 98, 0L }, new object[] { "E2", 99, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 97, 1L));
            AssertWindowAggAndPrev(
                epService.Container, listener,
                new object[][] { new object[] { "E2", 97, 1L }, new object[] { "E1", 98, 1L }, new object[] { "E3", 98, 0L } });
            stmt.Dispose();

            stmt         = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#groupwin(TheString)#rank(IntPrimitive, 2, DoublePrimitive) as ev");
            stmt.Events += listener.Update;

            var fields = "TheString,IntPrimitive,LongPrimitive,DoublePrimitive".Split(',');

            epService.EPRuntime.SendEvent(MakeEvent("E1", 100, 0L, 1d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 100, 0L, 1d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 100, 0L, 1d } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 100, 0L, 2d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2", 100, 0L, 2d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 100, 0L, 1d }, new object[] { "E2", 100, 0L, 2d } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 200, 0L, 0.5d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 200, 0L, 0.5d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 200, 0L, 0.5d }, new object[] { "E1", 100, 0L, 1d }, new object[] { "E2", 100, 0L, 2d } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 200, 0L, 2.5d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2", 200, 0L, 2.5d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 200, 0L, 0.5d }, new object[] { "E1", 100, 0L, 1d }, new object[] { "E2", 100, 0L, 2d }, new object[] { "E2", 200, 0L, 2.5d } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 300, 0L, 0.1d));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E1", 300, 0L, 0.1d }, new object[] { "E1", 100, 0L, 1d });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 300, 0L, 0.1d }, new object[] { "E1", 200, 0L, 0.5d }, new object[] { "E2", 100, 0L, 2d }, new object[] { "E2", 200, 0L, 2.5d } });

            stmt.Dispose();
        }
示例#11
0
        private void RunAssertionRanked(EPServiceProvider epService)
        {
            var fields   = "TheString,IntPrimitive,LongPrimitive".Split(',');
            var stmt     = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#rank(TheString, 4, IntPrimitive desc)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            // sorting-related testing
            epService.EPRuntime.SendEvent(MakeEvent("E1", 10, 0L));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 10, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 30, 0L));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2", 30, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 30, 0L }, new object[] { "E1", 10, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 50, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E1", 50, 0L }, new object[] { "E1", 10, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 50, 0L }, new object[] { "E2", 30, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E3", 40, 0L));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E3", 40, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 50, 0L }, new object[] { "E3", 40, 0L }, new object[] { "E2", 30, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 45, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E2", 45, 0L }, new object[] { "E2", 30, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 50, 0L }, new object[] { "E2", 45, 0L }, new object[] { "E3", 40, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 43, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E1", 43, 0L }, new object[] { "E1", 50, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 0L }, new object[] { "E1", 43, 0L }, new object[] { "E3", 40, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E3", 50, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E3", 50, 0L }, new object[] { "E3", 40, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E3", 50, 0L }, new object[] { "E2", 45, 0L }, new object[] { "E1", 43, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E3", 10, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E3", 10, 0L }, new object[] { "E3", 50, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 0L }, new object[] { "E1", 43, 0L }, new object[] { "E3", 10, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E4", 43, 0L));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E4", 43, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 0L }, new object[] { "E1", 43, 0L }, new object[] { "E4", 43, 0L }, new object[] { "E3", 10, 0L } });

            // in-place replacement
            epService.EPRuntime.SendEvent(MakeEvent("E4", 43, 1L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E4", 43, 1L }, new object[] { "E4", 43, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 0L }, new object[] { "E1", 43, 0L }, new object[] { "E4", 43, 1L }, new object[] { "E3", 10, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E2", 45, 1L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E2", 45, 1L }, new object[] { "E2", 45, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 1L }, new object[] { "E1", 43, 0L }, new object[] { "E4", 43, 1L }, new object[] { "E3", 10, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E1", 43, 1L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E1", 43, 1L }, new object[] { "E1", 43, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 1L }, new object[] { "E4", 43, 1L }, new object[] { "E1", 43, 1L }, new object[] { "E3", 10, 0L } });

            // out-of-space: pushing out the back end
            epService.EPRuntime.SendEvent(MakeEvent("E5", 10, 2L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E5", 10, 2L }, new object[] { "E3", 10, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 1L }, new object[] { "E4", 43, 1L }, new object[] { "E1", 43, 1L }, new object[] { "E5", 10, 2L } });

            epService.EPRuntime.SendEvent(MakeEvent("E5", 11, 3L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E5", 11, 3L }, new object[] { "E5", 10, 2L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 1L }, new object[] { "E4", 43, 1L }, new object[] { "E1", 43, 1L }, new object[] { "E5", 11, 3L } });

            epService.EPRuntime.SendEvent(MakeEvent("E6", 43, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E6", 43, 0L }, new object[] { "E5", 11, 3L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 45, 1L }, new object[] { "E4", 43, 1L }, new object[] { "E1", 43, 1L }, new object[] { "E6", 43, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E7", 50, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E7", 50, 0L }, new object[] { "E4", 43, 1L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E7", 50, 0L }, new object[] { "E2", 45, 1L }, new object[] { "E1", 43, 1L }, new object[] { "E6", 43, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E8", 45, 0L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E8", 45, 0L }, new object[] { "E1", 43, 1L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E7", 50, 0L }, new object[] { "E2", 45, 1L }, new object[] { "E8", 45, 0L }, new object[] { "E6", 43, 0L } });

            epService.EPRuntime.SendEvent(MakeEvent("E8", 46, 1L));
            EPAssertionUtil.AssertProps(listener.AssertPairGetIRAndReset(), fields, new object[] { "E8", 46, 1L }, new object[] { "E8", 45, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "E7", 50, 0L }, new object[] { "E8", 46, 1L }, new object[] { "E2", 45, 1L }, new object[] { "E6", 43, 0L } });

            stmt.Dispose();
        }