Ejemplo n.º 1
0
        public void RunOnMergeInsertUpdDeleteUngrouped(bool soda)
        {
            var eplDeclare = "create table varagg (p0 string, sumint sum(int))";

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplDeclare);

            var         fields   = "c0,c1".Split(',');
            var         eplRead  = "select varagg.p0 as c0, varagg.sumint as c1, varagg as c2 from SupportBean_S0";
            EPStatement stmtRead = SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplRead);

            stmtRead.AddListener(_listener);

            // assert selected column types
            var expectedAggType = new object[][] { new object[] { "c0", typeof(string) }, new object[] { "c1", typeof(int?) } };

            EventTypeAssertionUtil.AssertEventTypeProperties(expectedAggType, stmtRead.EventType, EventTypeAssertionEnum.NAME, EventTypeAssertionEnum.TYPE);

            // assert no row
            _epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { null, null });

            // create merge
            var eplMerge = "on SupportBean merge varagg" +
                           " when not matched then" +
                           " insert select TheString as p0" +
                           " when matched and TheString like \"U%\" then" +
                           " update set p0=\"updated\"" +
                           " when matched and TheString like \"D%\" then" +
                           " delete";

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplMerge);

            // merge for varagg
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 0));

            // assert
            _epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", null });

            // also aggregate-into the same key
            SupportModelHelper.CreateByCompileOrParse(_epService, soda, "into table varagg select sum(50) as sumint from SupportBean_S1");
            _epService.EPRuntime.SendEvent(new SupportBean_S1(0));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 50 });

            // update for varagg
            _epService.EPRuntime.SendEvent(new SupportBean("U2", 10));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            var received = _listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertProps(received, fields, new object[] { "updated", 50 });
            EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)received.Get("c2"), "p0,sumint".Split(','), new object[] { "updated", 50 });

            // delete for varagg
            _epService.EPRuntime.SendEvent(new SupportBean("D3", 0));
            _epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { null, null });

            _epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 2
0
        private void RunAssertionMinMaxNamedWindowWEver(EPServiceProvider epService, bool soda)
        {
            string[] fields = "lower,upper,lowerever,upperever".Split(',');
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "create window NamedWindow5m#length(2) as select * from SupportBean");
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "insert into NamedWindow5m select * from SupportBean");
            EPStatement stmt = SupportModelHelper.CreateByCompileOrParse(epService, soda, "select " +
                                                                         "min(IntPrimitive) as lower, " +
                                                                         "max(IntPrimitive) as upper, " +
                                                                         "minever(IntPrimitive) as lowerever, " +
                                                                         "maxever(IntPrimitive) as upperever from NamedWindow5m");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean(null, 1));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 1, 1, 1, 1 });

            epService.EPRuntime.SendEvent(new SupportBean(null, 5));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 1, 5, 1, 5 });

            epService.EPRuntime.SendEvent(new SupportBean(null, 3));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 3, 5, 1, 5 });

            epService.EPRuntime.SendEvent(new SupportBean(null, 6));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 3, 6, 1, 6 });

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 3
0
        private void TryAssertionFirstLastEver(EPServiceProvider epService, bool soda)
        {
            string[] fields = "c1,c2,c3".Split(',');
            string   epl    = "select " +
                              "firstever(IntBoxed,BoolPrimitive) as c1, " +
                              "lastever(IntBoxed,BoolPrimitive) as c2, " +
                              "countever(*,BoolPrimitive) as c3 " +
                              "from SupportBean#length(3)";
            EPStatement stmt     = SupportModelHelper.CreateByCompileOrParse(epService, soda, epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(MakeBean(100, false));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { null, null, 0L });

            epService.EPRuntime.SendEvent(MakeBean(100, true));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 100, 100, 1L });

            epService.EPRuntime.SendEvent(MakeBean(200, true));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 100, 200, 2L });

            epService.EPRuntime.SendEvent(MakeBean(201, false));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 100, 200, 2L });

            stmt.Dispose();
        }
Ejemplo n.º 4
0
        private void RunAssertionDatetimeTypes(bool soda)
        {
            var epl = "select " +
                      "cast(yyyymmdd,date,dateformat:\"yyyyMMdd\") as c0, " +
                      "cast(yyyymmdd,System.DateTime,dateformat:\"yyyyMMdd\") as c1, " +
                      "cast(yyyymmdd,long,dateformat:\"yyyyMMdd\") as c2, " +
                      "cast(yyyymmdd,System.Int64,dateformat:\"yyyyMMdd\") as c3, " +
                      "cast(yyyymmdd,date,dateformat:\"yyyyMMdd\").get(\"month\") as c6, " +
                      "cast(yyyymmdd,long,dateformat:\"yyyyMMdd\").get(\"month\") as c8 " +
                      "from MyType";
            var stmt = SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl);

            stmt.AddListener(_listener);

            var values = new Dictionary <string, object>();

            values.Put("yyyymmdd", "20100510");
            _epService.EPRuntime.SendEvent(values, "MyType");

            var formatYYYYMMdd = "yyyyMMdd";
            var dateYYMMddDate = DateTimeOffset.ParseExact("20100510", formatYYYYMMdd, null, DateTimeStyles.None);

            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "c0,c1,c2,c3,c6,c8".Split(','), new Object[] {
                dateYYMMddDate,
                dateYYMMddDate,
                dateYYMMddDate.TimeInMillis(),
                dateYYMMddDate.TimeInMillis(),
                5,
                5
            });

            stmt.Dispose();
        }
Ejemplo n.º 5
0
        public void RunAssertionMinMaxNamedWindowWEver(bool soda)
        {
            var fields = "lower,upper,lowerever,upperever".Split(',');

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, "create window NamedWindow5m.win:length(2) as select * from SupportBean");
            SupportModelHelper.CreateByCompileOrParse(_epService, soda, "insert into NamedWindow5m select * from SupportBean");
            var stmt = SupportModelHelper.CreateByCompileOrParse(_epService, soda, "select " +
                                                                 "min(IntPrimitive) as lower, " +
                                                                 "max(IntPrimitive) as upper, " +
                                                                 "minever(IntPrimitive) as lowerever, " +
                                                                 "maxever(IntPrimitive) as upperever from NamedWindow5m");

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(new SupportBean(null, 1));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { 1, 1, 1, 1 });

            _epService.EPRuntime.SendEvent(new SupportBean(null, 5));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { 1, 5, 1, 5 });

            _epService.EPRuntime.SendEvent(new SupportBean(null, 3));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { 3, 5, 1, 5 });

            _epService.EPRuntime.SendEvent(new SupportBean(null, 6));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { 3, 6, 1, 6 });

            _epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 6
0
        private void RunAssertionMultipleParams(bool soda)
        {
            var text      = "select irstream countboundary(1,10,IntPrimitive,*) as val from " + typeof(SupportBean).FullName;
            var statement = SupportModelHelper.CreateByCompileOrParse(_epService, soda, text);
            var listener  = new SupportUpdateListener();

            statement.AddListener(listener);

            var validContext = SupportPluginAggregationMethodThreeFactory.Contexts[0];

            EPAssertionUtil.AssertEqualsExactOrder(new Type[] { typeof(int?), typeof(int?), typeof(int), typeof(SupportBean) }, validContext.ParameterTypes);
            EPAssertionUtil.AssertEqualsExactOrder(new object[] { 1, 10, null, null }, validContext.ConstantValues);
            EPAssertionUtil.AssertEqualsExactOrder(new bool[] { true, true, false, false }, validContext.IsConstantValue);

            var e1 = new SupportBean("E1", 5);

            _epService.EPRuntime.SendEvent(e1);
            EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { 1 }, new object[] { 0 });
            EPAssertionUtil.AssertEqualsExactOrder(new object[] { 1, 10, 5, e1 }, SupportPluginAggregationMethodThree.LastEnterParameters);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 0));
            EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { 1 }, new object[] { 1 });

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 11));
            EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { 1 }, new object[] { 1 });

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRow(listener.AssertInvokedAndReset(), "val", new object[] { 2 }, new object[] { 1 });

            _epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertion3StreamAllUnidirectional(EPServiceProvider epService, bool soda)
        {
            string epl = "select * from SupportBean_A as a unidirectional " +
                         "full outer join SupportBean_B as b unidirectional " +
                         "full outer join SupportBean_C as c unidirectional";
            var listener = new SupportUpdateListener();

            SupportModelHelper.CreateByCompileOrParse(epService, soda, epl).Events += listener.Update;

            epService.EPRuntime.SendEvent(new SupportBean_A("A1"));
            AssertReceived3Stream(listener, "A1", null, null);

            epService.EPRuntime.SendEvent(new SupportBean_C("C1"));
            AssertReceived3Stream(listener, null, null, "C1");

            epService.EPRuntime.SendEvent(new SupportBean_C("C2"));
            AssertReceived3Stream(listener, null, null, "C2");

            epService.EPRuntime.SendEvent(new SupportBean_A("A2"));
            AssertReceived3Stream(listener, "A2", null, null);

            epService.EPRuntime.SendEvent(new SupportBean_B("B1"));
            AssertReceived3Stream(listener, null, "B1", null);

            epService.EPRuntime.SendEvent(new SupportBean_B("B2"));
            AssertReceived3Stream(listener, null, "B2", null);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 8
0
        private void RunAssertionFirstLastEver(bool soda)
        {
            var fields = "c1,c2,c3".Split(',');
            var epl    = "select " +
                         "firstever(IntBoxed,BoolPrimitive) as c1, " +
                         "lastever(IntBoxed,BoolPrimitive) as c2, " +
                         "countever(*,BoolPrimitive) as c3 " +
                         "from SupportBean#length(3)";
            var stmt = SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl);

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(MakeBean(100, false));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { null, null, 0L });

            _epService.EPRuntime.SendEvent(MakeBean(100, true));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { 100, 100, 1L });

            _epService.EPRuntime.SendEvent(MakeBean(200, true));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { 100, 200, 2L });

            _epService.EPRuntime.SendEvent(MakeBean(201, false));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { 100, 200, 2L });

            stmt.Dispose();
        }
Ejemplo n.º 9
0
        private void RunAssertionUngroupedParenSODA(bool soda)
        {
            var cols = "c0,c1,c2,c3,c4".Split(',');
            var epl  = "select LongPrimitive, " +
                       "sum(LongPrimitive) as c0, " +
                       "sum(group_by:(),LongPrimitive) as c1, " +
                       "sum(LongPrimitive,group_by:()) as c2, " +
                       "sum(LongPrimitive,group_by:TheString) as c3, " +
                       "sum(LongPrimitive,group_by:(TheString,IntPrimitive)) as c4" +
                       " from SupportBean";

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl).AddListener(_listener);

            MakeSendEvent("E1", 1, 10);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { 10L, 10L, 10L, 10L, 10L });

            MakeSendEvent("E1", 2, 11);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { 21L, 21L, 21L, 21L, 11L });

            MakeSendEvent("E2", 1, 12);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { 33L, 33L, 33L, 12L, 12L });

            MakeSendEvent("E2", 2, 13);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), cols, new object[] { 46L, 46L, 46L, 25L, 13L });

            _epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 10
0
        private void TryAssertionFromClauseAsMultiple(EPServiceProvider epService, bool soda)
        {
            var epl = "on OrderEvent as oe " +
                      "insert into StartEvent select oe.orderdetail.OrderId as oi " +
                      "insert into ThenEvent select * from [select oe.orderdetail.OrderId as oi, ItemId from orderdetail.Items] as item " +
                      "insert into MoreEvent select oe.orderdetail.OrderId as oi, item.ItemId as ItemId from [select oe, * from orderdetail.Items] as item " +
                      "output all";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, epl);

            var listeners = GetListeners();

            epService.EPAdministrator.CreateEPL("select * from StartEvent").Events += listeners[0].Update;
            epService.EPAdministrator.CreateEPL("select * from ThenEvent").Events  += listeners[1].Update;
            epService.EPAdministrator.CreateEPL("select * from MoreEvent").Events  += listeners[2].Update;

            epService.EPRuntime.SendEvent(OrderBeanFactory.MakeEventOne());
            var fieldsOrderId = "oi".Split(',');
            var fieldsItems   = "oi,ItemId".Split(',');

            EPAssertionUtil.AssertProps(listeners[0].AssertOneGetNewAndReset(), fieldsOrderId, new object[] { "PO200901" });
            var expected = new[] { new object[] { "PO200901", "A001" }, new object[] { "PO200901", "A002" }, new object[] { "PO200901", "A003" } };

            EPAssertionUtil.AssertPropsPerRow(listeners[1].GetAndResetDataListsFlattened().First, fieldsItems, expected);
            EPAssertionUtil.AssertPropsPerRow(listeners[2].GetAndResetDataListsFlattened().First, fieldsItems, expected);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 11
0
        private void TryAssertionIntegerIndexedPropertyLookAlike(EPServiceProvider epService, bool soda)
        {
            var eplDeclare = "create table varaggIIP (key int primary key, myevents window(*) @Type('SupportBean'))";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplDeclare);

            var eplInto =
                "into table varaggIIP select window(*) as myevents from SupportBean#length(3) group by IntPrimitive";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplInto);

            var eplSelect =
                "select varaggIIP[1] as c0, varaggIIP[1].myevents as c1, varaggIIP[1].myevents.last(*) as c2 from SupportBean_S0";
            var stmt     = SupportModelHelper.CreateByCompileOrParse(epService, soda, eplSelect);
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var e1 = MakeSendBean(epService, "E1", 1, 10L);
            var e2 = MakeSendBean(epService, "E2", 1, 20L);

            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            AssertIntegerIndexed(listener.AssertOneGetNewAndReset(), new SupportBean[] { e1, e2 });

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 12
0
        private void RunAssertion(bool soda, string pattern, string propertyNames, bool[] arrayProp,
                                  string[] sequencesWithMatch,
                                  string[] sequencesNoMatch)
        {
            var props    = propertyNames.Split(',');
            var measures = MakeMeasures(props);
            var defines  = MakeDefines(props);

            var text = "select * from SupportBean " +
                       "match_recognize (" +
                       " partition by intPrimitive" +
                       " measures " + measures +
                       " pattern (" + pattern + ")" +
                       " define " + defines +
                       ")";

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, text).AddListener(_listener);

            var sequenceNum = 0;

            for (var i = 0; i < sequencesWithMatch.Length; i++)
            {
                RunAssertionSequence(true, props, arrayProp, sequenceNum, sequencesWithMatch[i]);
                sequenceNum++;
            }

            for (var i = 0; i < sequencesNoMatch.Length; i++)
            {
                RunAssertionSequence(false, props, arrayProp, sequenceNum, sequencesNoMatch[i]);
                sequenceNum++;
            }

            _epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 13
0
        private void RunAssertionFromClauseBeginBodyEnd(bool soda)
        {
            String epl = "on OrderEvent " +
                         "insert into BeginEvent select orderdetail.OrderId as OrderId " +
                         "insert into OrderItem select * from [select orderdetail.OrderId as OrderId, * from orderdetail.Items] " +
                         "insert into EndEvent select orderdetail.OrderId as OrderId " +
                         "output all";

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl);

            _epService.EPAdministrator.CreateEPL("select * from BeginEvent").AddListener(_listeners[0]);
            _epService.EPAdministrator.CreateEPL("select * from OrderItem").AddListener(_listeners[1]);
            _epService.EPAdministrator.CreateEPL("select * from EndEvent").AddListener(_listeners[2]);

            EventType typeOrderItem = _epService.EPAdministrator.Configuration.GetEventType("OrderItem");

            Assert.AreEqual("[Amount, ItemId, OrderId, Price, ProductId]", CompatExtensions.Render(Enumerable.OrderBy(typeOrderItem.PropertyNames, propName => propName)));

            _epService.EPRuntime.SendEvent(OrderBeanFactory.MakeEventOne());
            AssertFromClauseWContained("PO200901", new Object[][] { new Object[] { "PO200901", "A001" }, new Object[] { "PO200901", "A002" }, new Object[] { "PO200901", "A003" } });

            _epService.EPRuntime.SendEvent(OrderBeanFactory.MakeEventTwo());
            AssertFromClauseWContained("PO200902", new Object[][] { new Object[] { "PO200902", "B001" } });

            _epService.EPRuntime.SendEvent(OrderBeanFactory.MakeEventFour());
            AssertFromClauseWContained("PO200904", new Object[0][]);

            _epService.EPAdministrator.DestroyAllStatements();
        }
        private void RunAssertionDefineNotPresent(EPServiceProvider engine, bool soda)
        {
            SupportUpdateListener listener = new SupportUpdateListener();
            string epl = "select * from SupportBean " +
                         "match_recognize (" +
                         " measures A as a, B as b" +
                         " pattern (A B)" +
                         ")";
            EPStatement stmt = SupportModelHelper.CreateByCompileOrParse(engine, soda, epl);

            stmt.AddListener(listener);

            string[]      fields = "a,b".Split(',');
            SupportBean[] beans  = new SupportBean[4];
            for (int i = 0; i < beans.Length; i++)
            {
                beans[i] = new SupportBean("E" + i, i);
            }

            engine.EPRuntime.SendEvent(beans[0]);
            Assert.IsFalse(listener.IsInvoked);
            engine.EPRuntime.SendEvent(beans[1]);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { beans[0], beans[1] });

            engine.EPRuntime.SendEvent(beans[2]);
            Assert.IsFalse(listener.IsInvoked);
            engine.EPRuntime.SendEvent(beans[3]);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { beans[2], beans[3] });

            stmt.Dispose();
        }
Ejemplo n.º 15
0
        private void RunAssertionScriptReturningEvents(bool soda)
        {
            String script = string.Join(
                "\n",
                "create expression EventBean[] @type(ItemEvent) jscript:myScriptReturnsEvents() [",
                "  function myScriptReturnsEvents() {",
                "    var events = host.newArr(EventBean, 3);",
                "    events[0] = epl.EventBeanService.AdapterForMap(Collections.SingletonDataMap(\"id\", \"id1\"), \"ItemEvent\");",
                "    events[1] = epl.EventBeanService.AdapterForMap(Collections.SingletonDataMap(\"id\", \"id2\"), \"ItemEvent\");",
                "    events[2] = epl.EventBeanService.AdapterForMap(Collections.SingletonDataMap(\"id\", \"id3\"), \"ItemEvent\");",
                "    return events;",
                "  }",
                "  return myScriptReturnsEvents();",
                "]"
                );

            EPStatement stmtScript = SupportModelHelper.CreateByCompileOrParse(_epService, soda, script);

            EPStatement stmtSelect = _epService.EPAdministrator.CreateEPL("select myScriptReturnsEvents().where(v => v.id in ('id1', 'id3')) as c0 from SupportBean");

            stmtSelect.AddListener(_listener);

            _epService.EPRuntime.SendEvent(new SupportBean());
            var coll = _listener.AssertOneGetNewAndReset().Get("c0").Unwrap <Map>();

            EPAssertionUtil.AssertPropsPerRow(coll.ToArray(), "id".SplitCsv(), new Object[][] { new Object[] { "id1" }, new Object[] { "id3" } });

            stmtSelect.Dispose();
            stmtScript.Dispose();
        }
        private void RunAssertionExecCtx(EPServiceProvider epService, bool soda)
        {
            string epl = "select " +
                         "current_evaluation_context() as c0, " +
                         "current_evaluation_context(), " +
                         "current_evaluation_context().get_EngineURI() as c2 from SupportBean";
            EPStatement stmt     = SupportModelHelper.CreateByCompileOrParse(epService, soda, epl, "my_user_object");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            Assert.AreEqual(typeof(EPLExpressionEvaluationContext), stmt.EventType.GetPropertyType("current_evaluation_context()"));

            epService.EPRuntime.SendEvent(new SupportBean());
            EventBean @event = listener.AssertOneGetNewAndReset();
            EPLExpressionEvaluationContext ctx = (EPLExpressionEvaluationContext)@event.Get("c0");

            Assert.AreEqual(epService.URI, ctx.EngineURI);
            Assert.AreEqual(stmt.Name, ctx.StatementName);
            Assert.AreEqual(-1, ctx.ContextPartitionId);
            Assert.AreEqual("my_user_object", ctx.StatementUserObject);
            Assert.AreEqual(epService.URI, @event.Get("c2"));

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 17
0
        private void RunAssertionNewInstance(bool soda)
        {
            _epService.EPAdministrator.Configuration.AddImport(typeof(SupportBean));

            var epl = "select " +
                      "new SupportBean(\"A\",IntPrimitive) as c0, " +
                      "new SupportBean(\"B\",IntPrimitive+10), " +
                      "new SupportBean() as c2, " +
                      "new SupportBean(\"ABC\",0).get_TheString() as c3 " +
                      "from SupportBean";
            var stmt = SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl);

            stmt.AddListener(_listener);
            var expectedAggType = new object[][] { new object[] { "c0", typeof(SupportBean) }, new object[] { "new SupportBean(\"B\",IntPrimitive+10)", typeof(SupportBean) } };

            EventTypeAssertionUtil.AssertEventTypeProperties(expectedAggType, stmt.EventType, EventTypeAssertionEnum.NAME, EventTypeAssertionEnum.TYPE);

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

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 10));
            var @event = _listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertPropsPONO(@event.Get("c0"), fields, new object[] { "A", 10 });
            EPAssertionUtil.AssertPropsPONO(((IDictionary <string, object>)@event.Underlying).Get("new SupportBean(\"B\",IntPrimitive+10)"), fields, new object[] { "B", 20 });
            EPAssertionUtil.AssertPropsPONO(@event.Get("c2"), fields, new object[] { null, 0 });
            Assert.AreEqual("ABC", @event.Get("c3"));

            _epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 18
0
        private void RunAssertionFirstLastEver(bool soda)
        {
            string[] fields = "firsteverstring,firsteverint,lasteverstring,lasteverint,counteverstar,counteverexpr,counteverexprfilter".Split(',');

            string epl = "select " +
                         "firstever(TheString) as firsteverstring, " +
                         "lastever(TheString) as lasteverstring, " +
                         "firstever(IntPrimitive) as firsteverint, " +
                         "lastever(IntPrimitive) as lasteverint, " +
                         "countever(*) as counteverstar, " +
                         "countever(IntBoxed) as counteverexpr, " +
                         "countever(IntBoxed,BoolPrimitive) as counteverexprfilter " +
                         "from SupportBean.win:length(2)";
            EPStatement stmt = SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl);

            stmt.AddListener(_listener);

            MakeSendBean("E1", 10, 100, true);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 10, "E1", 10, 1L, 1L, 1L });

            MakeSendBean("E2", 11, null, true);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 10, "E2", 11, 2L, 1L, 1L });

            MakeSendBean("E3", 12, 120, false);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 10, "E3", 12, 3L, 2L, 1L });

            stmt.Dispose();
        }
Ejemplo n.º 19
0
        private void RunAssertion(EPServiceProvider epService, bool soda, string pattern, string propertyNames, bool[] arrayProp,
                                  string[] sequencesWithMatch,
                                  string[] sequencesNoMatch)
        {
            var props    = propertyNames.Split(',');
            var measures = MakeMeasures(props);
            var defines  = MakeDefines(props);

            var text = "select * from SupportBean " +
                       "match_recognize (" +
                       " partition by IntPrimitive" +
                       " measures " + measures +
                       " pattern (" + pattern + ")" +
                       " define " + defines +
                       ")";
            var listener = new SupportUpdateListener();

            SupportModelHelper.CreateByCompileOrParse(epService, soda, text).Events += listener.Update;

            var sequenceNum = 0;

            foreach (var aSequencesWithMatch in sequencesWithMatch)
            {
                RunAssertionSequence(epService, listener, true, props, arrayProp, sequenceNum, aSequencesWithMatch);
                sequenceNum++;
            }

            foreach (var aSequencesNoMatch in sequencesNoMatch)
            {
                RunAssertionSequence(epService, listener, false, props, arrayProp, sequenceNum, aSequencesNoMatch);
                sequenceNum++;
            }

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 20
0
        private void RunAssertion3StreamAllUnidirectional(bool soda)
        {
            string epl = "select * from SupportBean_A as a unidirectional " +
                         "full outer join SupportBean_B as b unidirectional " +
                         "full outer join SupportBean_C as c unidirectional";

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl).AddListener(_listener);

            _epService.EPRuntime.SendEvent(new SupportBean_A("A1"));
            AssertReceived3Stream("A1", null, null);

            _epService.EPRuntime.SendEvent(new SupportBean_C("C1"));
            AssertReceived3Stream(null, null, "C1");

            _epService.EPRuntime.SendEvent(new SupportBean_C("C2"));
            AssertReceived3Stream(null, null, "C2");

            _epService.EPRuntime.SendEvent(new SupportBean_A("A2"));
            AssertReceived3Stream("A2", null, null);

            _epService.EPRuntime.SendEvent(new SupportBean_B("B1"));
            AssertReceived3Stream(null, "B1", null);

            _epService.EPRuntime.SendEvent(new SupportBean_B("B2"));
            AssertReceived3Stream(null, "B2", null);

            _epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 21
0
        private void TryAssertionSchemaArrayPrimitiveType(EPServiceProvider epService, bool soda)
        {
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "create schema MySchema as (c0 int[primitive], c1 int[])");
            var expectedType = new object[][] { new object[] { "c0", typeof(int[]) }, new object[] { "c1", typeof(int[]) } };

            SupportEventTypeAssertionUtil.AssertEventTypeProperties(expectedType, epService.EPAdministrator.Configuration.GetEventType("MySchema"), SupportEventTypeAssertionEnum.NAME, SupportEventTypeAssertionEnum.TYPE);
            epService.EPAdministrator.Configuration.RemoveEventType("MySchema", true);
        }
Ejemplo n.º 22
0
        private void RunAssertionGroupedMixedMethodAndAccess(bool soda)
        {
            var eplDeclare = "create table varMyAgg (" +
                             "key string primary key, " +
                             "c0 count(*), " +
                             "c1 count(distinct object), " +
                             "c2 window(*) @type('SupportBean'), " +
                             "c3 sum(long)" +
                             ")";

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplDeclare);

            var eplBind = "into table varMyAgg select " +
                          "count(*) as c0, " +
                          "count(distinct IntPrimitive) as c1, " +
                          "window(*) as c2, " +
                          "sum(LongPrimitive) as c3 " +
                          "from SupportBean.win:length(3) group by TheString";

            SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplBind);

            var eplSelect = "select " +
                            "varMyAgg[p00].c0 as c0, " +
                            "varMyAgg[p00].c1 as c1, " +
                            "varMyAgg[p00].c2 as c2, " +
                            "varMyAgg[p00].c3 as c3" +
                            " from SupportBean_S0";
            var stmtSelect = SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplSelect);

            stmtSelect.AddListener(_listener);
            var fields = "c0,c1,c2,c3".Split(',');

            Assert.AreEqual(typeof(long?), stmtSelect.EventType.GetPropertyType("c0"));
            Assert.AreEqual(typeof(long?), stmtSelect.EventType.GetPropertyType("c1"));
            Assert.AreEqual(typeof(SupportBean[]), stmtSelect.EventType.GetPropertyType("c2"));
            Assert.AreEqual(typeof(long?), stmtSelect.EventType.GetPropertyType("c3"));

            var b1 = MakeSendBean("E1", 10, 100);
            var b2 = MakeSendBean("E1", 11, 101);
            var b3 = MakeSendBean("E1", 10, 102);

            _epService.EPRuntime.SendEvent(new SupportBean_S0(0, "E1"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 3L, 2L, new SupportBean[] { b1, b2, b3 }, 303L });

            _epService.EPRuntime.SendEvent(new SupportBean_S0(0, "E2"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { null, null, null, null });

            var b4 = MakeSendBean("E2", 20, 200);

            _epService.EPRuntime.SendEvent(new SupportBean_S0(0, "E2"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 1L, 1L, new SupportBean[] { b4 }, 200L });

            _epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 23
0
        private void RunAssertionNestedMultivalueAccess(EPServiceProvider epService, bool grouped, bool soda)
        {
            string eplDeclare = "create table varagg (" +
                                (grouped ? "key string primary key, " : "") + "windowSupportBean window(*) @Type('SupportBean'))";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplDeclare);

            string eplInto = "into table varagg " +
                             "select window(*) as windowSupportBean from SupportBean#length(2)" +
                             (grouped ? " group by TheString" : "");

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplInto);

            string key       = grouped ? "[\"E1\"]" : "";
            string eplSelect = "select " +
                               "varagg" + key + ".windowSupportBean.last(*) as c0, " +
                               "varagg" + key + ".windowSupportBean.window(*) as c1, " +
                               "varagg" + key + ".windowSupportBean.first(*) as c2, " +
                               "varagg" + key + ".windowSupportBean.last(IntPrimitive) as c3, " +
                               "varagg" + key + ".windowSupportBean.window(IntPrimitive) as c4, " +
                               "varagg" + key + ".windowSupportBean.first(IntPrimitive) as c5" +
                               " from SupportBean_S0";
            EPStatement stmtSelect = SupportModelHelper.CreateByCompileOrParse(epService, soda, eplSelect);
            var         listener   = new SupportUpdateListener();

            stmtSelect.Events += listener.Update;
            var expectedAggType = new object[][] {
                new object[] { "c0", typeof(SupportBean) }, new object[] { "c1", typeof(SupportBean[]) }, new object[] { "c2", typeof(SupportBean) },
                new object[] { "c3", typeof(int) }, new object[] { "c4", typeof(int[]) }, new object[] { "c5", typeof(int) }
            };

            SupportEventTypeAssertionUtil.AssertEventTypeProperties(expectedAggType, stmtSelect.EventType, SupportEventTypeAssertionEnum.NAME, SupportEventTypeAssertionEnum.TYPE);

            string[]    fields = "c0,c1,c2,c3,c4,c5".Split(',');
            SupportBean b1     = MakeSendBean(epService, "E1", 10);

            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { b1, new object[] { b1 }, b1, 10, new int[] { 10 }, 10 });

            SupportBean b2 = MakeSendBean(epService, "E1", 20);

            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { b2, new object[] { b1, b2 }, b1, 20, new int[] { 10, 20 }, 10 });

            SupportBean b3 = MakeSendBean(epService, "E1", 30);

            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { b3, new object[] { b2, b3 }, b2, 30, new int[] { 20, 30 }, 20 });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("table_varagg__internal", false);
            epService.EPAdministrator.Configuration.RemoveEventType("table_varagg__public", false);
        }
Ejemplo n.º 24
0
        private void RunPlainPropertyWDatetimeEtc(EPServiceProvider epService, bool grouped, bool soda)
        {
            string myBean = typeof(MyBean).MaskTypeName();

            SupportModelHelper.CreateByCompileOrParse(
                epService, soda, "create objectarray schema MyEvent as (p0 string)");
            SupportModelHelper.CreateByCompileOrParse(
                epService, soda, "create objectarray schema PopulateEvent as (" +
                "key string" +
                ", ts long" +
                ", mb " + myBean +
                ", mbarr " + myBean + "[]" +
                ", me MyEvent" +
                ", mearr MyEvent[])");

            string eplDeclare = "create table varaggPWD (key string" + (grouped ? " primary key" : "") +
                                ", ts long" +
                                ", mb " + myBean +
                                ", mbarr " + myBean + "[]" +
                                ", me MyEvent" +
                                ", mearr MyEvent[])";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplDeclare);

            string key       = grouped ? "[\"E1\"]" : "";
            string eplSelect = "select " +
                               "varaggPWD" + key + ".ts.getMinuteOfHour() as c0, " +
                               "varaggPWD" + key + ".mb.MyProperty as c1, " +
                               "varaggPWD" + key + ".mbarr.takeLast(1) as c2, " +
                               "varaggPWD" + key + ".me.p0 as c3, " +
                               "varaggPWD" + key + ".mearr.selectFrom(i => i.p0) as c4 " +
                               "from SupportBean_S0";
            var listener = new SupportUpdateListener();

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplSelect).Events += listener.Update;

            string eplMerge = "on PopulateEvent merge varaggPWD " +
                              "when not matched then insert " +
                              "select key, ts, mb, mbarr, me, mearr";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplMerge);

            object[] @event = MakePopulateEvent();
            epService.EPRuntime.SendEvent(@event, "PopulateEvent");
            epService.EPRuntime.SendEvent(new SupportBean_S0(0, "E1"));
            EventBean output = listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertProps(
                output, "c0,c1,c3".Split(','),
                new object[] { 55, "x", "p0value" });
            Assert.AreEqual(1, ((ICollection <object>)output.Get("c2")).Count);
            Assert.AreEqual("[0_p0, 1_p0]", output.Get("c4").RenderAny());

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 25
0
        private void TryAssertionNestedDotMethod(EPServiceProvider epService, bool grouped, bool soda)
        {
            string eplDeclare = "create table varaggNDM (" +
                                (grouped ? "key string primary key, " : "") +
                                "windowSupportBean window(*) @Type('SupportBean'))";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplDeclare);

            string eplInto = "into table varaggNDM " +
                             "select window(*) as windowSupportBean from SupportBean#length(2)" +
                             (grouped ? " group by TheString" : "");

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplInto);

            string key       = grouped ? "[\"E1\"]" : "";
            string eplSelect = "select " +
                               "varaggNDM" + key + ".windowSupportBean.last(*).IntPrimitive as c0, " +
                               "varaggNDM" + key + ".windowSupportBean.window(*).countOf() as c1, " +
                               "varaggNDM" + key + ".windowSupportBean.window(IntPrimitive).take(1) as c2" +
                               " from SupportBean_S0";
            EPStatement stmtSelect = SupportModelHelper.CreateByCompileOrParse(epService, soda, eplSelect);
            var         listener   = new SupportUpdateListener();

            stmtSelect.Events += listener.Update;
            var expectedAggType = new object[][] {
                new object[] { "c0", typeof(int?) },
                new object[] { "c1", typeof(int) },
                new object[] { "c2", typeof(ICollection <int>) }
            };

            SupportEventTypeAssertionUtil.AssertEventTypeProperties(
                expectedAggType, stmtSelect.EventType, SupportEventTypeAssertionEnum.NAME,
                SupportEventTypeAssertionEnum.TYPE);

            string[] fields = "c0,c1,c2".Split(',');
            MakeSendBean(epService, "E1", 10, 0);
            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(
                listener.AssertOneGetNewAndReset(), fields, new object[] { 10, 1, Collections.SingletonList(10) });

            MakeSendBean(epService, "E1", 20, 0);
            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(
                listener.AssertOneGetNewAndReset(), fields, new object[] { 20, 2, Collections.SingletonList(10) });

            MakeSendBean(epService, "E1", 30, 0);
            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(
                listener.AssertOneGetNewAndReset(), fields, new object[] { 30, 2, Collections.SingletonList(20) });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("table_varaggNDM__internal", false);
            epService.EPAdministrator.Configuration.RemoveEventType("table_varaggNDM__public", false);
        }
Ejemplo n.º 26
0
        private void RunAssertionEventBeanArray(string methodName, bool soda)
        {
            string epl = "select p0 from SupportBean, "
                         + "method:" + typeof(SupportStaticMethodLib).FullName
                         + "." + methodName + "(theString) @Type(MyItemEvent)";
            EPStatement stmt = SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl);

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(new SupportBean("a,b", 0));
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), "p0".SplitCsv(), new Object[][] { new Object[] { "a" }, new Object[] { "b" } });
        }
Ejemplo n.º 27
0
        private void RunAssertionType(bool namedWindow)
        {
            string eplCreate = namedWindow ?
                               "create window MyInfra#keepall as (c0 int[], c1 int[primitive])" :
                               "create table MyInfra (c0 int[], c1 int[primitive])";
            EPStatement stmt = SupportModelHelper.CreateByCompileOrParse(_epService, false, eplCreate);

            object[][] expectedType = new object[][] { new object[] { "c0", typeof(int[]) }, new object[] { "c1", typeof(int[]) } };
            SupportEventTypeAssertionUtil.AssertEventTypeProperties(expectedType, stmt.EventType, SupportEventTypeAssertionEnum.NAME, SupportEventTypeAssertionEnum.TYPE);

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false);
        }
Ejemplo n.º 28
0
        private void RunAssertionMinMax(bool soda)
        {
            string[] fields     = "maxb,maxu,minb,minu".Split(',');
            string   eplDeclare = "create table varagg (" +
                                  "maxb max(int), maxu maxever(int), minb min(int), minu minever(int))";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplDeclare);

            string      eplIterate  = "select varagg from SupportBean_S0#lastevent";
            EPStatement stmtIterate = SupportModelHelper.CreateByCompileOrParse(epService, soda, eplIterate);

            epService.EPRuntime.SendEvent(new SupportBean_S0(0));

            string eplBoundInto = "into table varagg select " +
                                  "max(IntPrimitive) as maxb, min(IntPrimitive) as minb " +
                                  "from SupportBean#length(2)";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplBoundInto);

            string eplUnboundInto = "into table varagg select " +
                                    "maxever(IntPrimitive) as maxu, minever(IntPrimitive) as minu " +
                                    "from SupportBean";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplUnboundInto);

            epService.EPRuntime.SendEvent(new SupportBean("E1", 20));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 15));
            epService.EPRuntime.SendEvent(new SupportBean("E3", 10));
            AssertResults(stmtIterate, fields, new object[] { 15, 20, 10, 10 });

            epService.EPRuntime.SendEvent(new SupportBean("E4", 5));
            AssertResults(stmtIterate, fields, new object[] { 10, 20, 5, 5 });

            epService.EPRuntime.SendEvent(new SupportBean("E5", 25));
            AssertResults(stmtIterate, fields, new object[] { 25, 25, 5, 5 });

            // invalid: unbound aggregation into bound max
            SupportMessageAssertUtil.TryInvalid(epService, "into table varagg select max(IntPrimitive) as maxb from SupportBean",
                                                "Error starting statement: Incompatible aggregation function for table 'varagg' column 'maxb', expecting 'max(int)' and received 'max(IntPrimitive)': The aggregation declares use with data windows and provided is unbound [");

            // valid: bound with unbound variable
            string eplBoundIntoUnbound = "into table varagg select " +
                                         "maxever(IntPrimitive) as maxu, minever(IntPrimitive) as minu " +
                                         "from SupportBean#length(2)";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplBoundIntoUnbound);

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("table_varagg__internal", false);
            epService.EPAdministrator.Configuration.RemoveEventType("table_varagg__public", false);
        }
Ejemplo n.º 29
0
        private void RunAssertionEventIndexOnTriggerNWInsertRemove(EPServiceProvider epService, bool soda)
        {
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "create window MyWindow#length(5) as select * from SupportSpatialPoint");
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "create index MyIndex on MyWindow((px,py) pointregionquadtree(0,0,100,100))");
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "insert into MyWindow select * from SupportSpatialPoint");

            var epl = IndexBackingTableInfo.INDEX_CALLBACK_HOOK + " on SupportSpatialAABB as aabb " +
                      "select points.id as c0 from MyWindow as points where point(px,py).inside(rectangle(x,y,width,height))";
            var stmt     = SupportModelHelper.CreateByCompileOrParse(epService, soda, epl);
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SupportQueryPlanIndexHook.AssertOnExprTableAndReset("MyIndex", "non-unique hash={} btree={} advanced={pointregionquadtree(px,py)}");

            SendPoint(epService, "P1", 10, 40);
            AssertRectanglesManyRow(epService, listener, BOXES, "P1", null, null, null, null);

            SendPoint(epService, "P2", 80, 80);
            AssertRectanglesManyRow(epService, listener, BOXES, "P1", null, null, "P2", null);

            SendPoint(epService, "P3", 10, 40);
            AssertRectanglesManyRow(epService, listener, BOXES, "P1,P3", null, null, "P2", null);

            SendPoint(epService, "P4", 60, 40);
            AssertRectanglesManyRow(epService, listener, BOXES, "P1,P3", "P4", null, "P2", "P4");

            SendPoint(epService, "P5", 20, 75);
            AssertRectanglesManyRow(epService, listener, BOXES, "P1,P3", "P4", "P5", "P2", "P4");

            SendPoint(epService, "P6", 50, 50);
            AssertRectanglesManyRow(epService, listener, BOXES, "P3", "P4", "P5", "P2,P6", "P4,P6");

            SendPoint(epService, "P7", 0, 0);
            AssertRectanglesManyRow(epService, listener, BOXES, "P3,P7", "P4", "P5", "P6", "P4,P6");

            SendPoint(epService, "P8", 99.999, 0);
            AssertRectanglesManyRow(epService, listener, BOXES, "P7", "P4,P8", "P5", "P6", "P4,P6");

            SendPoint(epService, "P9", 0, 99.999);
            AssertRectanglesManyRow(epService, listener, BOXES, "P7", "P8", "P5,P9", "P6", "P6");

            SendPoint(epService, "P10", 99.999, 99.999);
            AssertRectanglesManyRow(epService, listener, BOXES, "P7", "P8", "P9", "P6,P10", "P6");

            SendPoint(epService, "P11", 0, 0);
            AssertRectanglesManyRow(epService, listener, BOXES, "P7,P11", "P8", "P9", "P10", null);

            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 30
0
        private void RunAggregationWDatetimeEtc(EPServiceProvider epService, bool grouped, bool soda)
        {
            string eplDeclare = "create table varaggWDE (" + (grouped ? "key string primary key, " : "") +
                                "a1 lastever(long), a2 window(*) @Type('SupportBean'))";

            SupportModelHelper.CreateByCompileOrParse(epService, soda, eplDeclare);

            string eplInto = "into table varaggWDE " +
                             "select lastever(LongPrimitive) as a1, window(*) as a2 from SupportBean#time(10 seconds)" +
                             (grouped ? " group by TheString" : "");
            EPStatement stmtInto        = SupportModelHelper.CreateByCompileOrParse(epService, soda, eplInto);
            var         expectedAggType = new object[][] {
                new object[] { "a1", typeof(long) },
                new object[] { "a2", typeof(SupportBean[]) }
            };

            SupportEventTypeAssertionUtil.AssertEventTypeProperties(
                expectedAggType, stmtInto.EventType, SupportEventTypeAssertionEnum.NAME,
                SupportEventTypeAssertionEnum.TYPE);

            string key    = grouped ? "[\"E1\"]" : "";
            string eplGet = "select varaggWDE" + key + ".a1.after(150L) as c0, " +
                            "varaggWDE" + key + ".a2.countOf() as c1 from SupportBean_S0";
            EPStatement stmtGet  = SupportModelHelper.CreateByCompileOrParse(epService, soda, eplGet);
            var         listener = new SupportUpdateListener();

            stmtGet.Events += listener.Update;
            var expectedGetType =
                new object[][] {
                new object[] { "c0", typeof(bool?) },
                new object[] { "c1", typeof(int) }
            };

            SupportEventTypeAssertionUtil.AssertEventTypeProperties(
                expectedGetType, stmtGet.EventType, SupportEventTypeAssertionEnum.NAME,
                SupportEventTypeAssertionEnum.TYPE);

            string[] fields = "c0,c1".Split(',');
            MakeSendBean(epService, "E1", 10, 100);
            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { false, 1 });

            MakeSendBean(epService, "E1", 20, 200);
            epService.EPRuntime.SendEvent(new SupportBean_S0(0));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { true, 2 });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("table_varaggWDE__internal", false);
            epService.EPAdministrator.Configuration.RemoveEventType("table_varaggWDE__public", false);
        }