示例#1
0
        private void RunAssertionEventIndexChoiceOfTwo(EPServiceProvider epService)
        {
            var epl =
                "create table MyPointTable(" +
                " id string primary key," +
                " x1 double, y1 double, \n" +
                " x2 double, y2 double);\n" +
                "create index Idx1 on MyPointTable( (x1, y1) pointregionquadtree(0, 0, 100, 100));\n" +
                "create index Idx2 on MyPointTable( (x2, y2) pointregionquadtree(0, 0, 100, 100));\n" +
                "on SupportSpatialDualPoint dp merge MyPointTable t where dp.id = t.id when not matched then insert select dp.id as id,x1,y1,x2,y2;\n";
            var deploymentId = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl).DeploymentId;

            var textOne      = IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "on SupportSpatialAABB select tbl.id as c0 from MyPointTable as tbl where point(x1, y1).inside(rectangle(x, y, width, height))";
            var statementOne = epService.EPAdministrator.CreateEPL(textOne);
            var listener     = new SupportUpdateListener();

            statementOne.Events += listener.Update;
            SupportQueryPlanIndexHook.AssertOnExprTableAndReset("Idx1", "non-unique hash={} btree={} advanced={pointregionquadtree(x1,y1)}");

            var textTwo      = IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "on SupportSpatialAABB select tbl.id as c0 from MyPointTable as tbl where point(tbl.x2, y2).inside(rectangle(x, y, width, height))";
            var statementTwo = epService.EPAdministrator.CreateEPL(textTwo);

            statementTwo.Events += listener.Update;
            SupportQueryPlanIndexHook.AssertOnExprTableAndReset("Idx2", "non-unique hash={} btree={} advanced={pointregionquadtree(x2,y2)}");

            epService.EPRuntime.SendEvent(new SupportSpatialDualPoint("P1", 10, 10, 60, 60));
            epService.EPRuntime.SendEvent(new SupportSpatialDualPoint("P2", 55, 20, 4, 88));

            AssertRectanglesSingleValue(epService, listener, BOXES, "P1", "P2", "P2", "P1", "P1");

            statementOne.Dispose();
            statementTwo.Dispose();
            epService.EPAdministrator.DeploymentAdmin.Undeploy(deploymentId);
        }
示例#2
0
        private void RunAssertionEventIndexOnTriggerTable(EPServiceProvider epService)
        {
            var epl =
                "create table MyPointTable(my_x double primary key, my_y double primary key, my_id string);\n" +
                "@Audit create index MyIndex on MyPointTable( (my_x, my_y) pointregionquadtree(0, 0, 100, 100));\n" +
                "on SupportSpatialPoint ssp merge MyPointTable where ssp.px = my_x and ssp.py = my_y when not matched then insert select px as my_x, py as my_y, id as my_id;\n" +
                IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                "@Audit @Name('s0') on SupportSpatialAABB select my_id as c0 from MyPointTable as c0 where point(my_x, my_y).inside(rectangle(x, y, width, height))";
            var deploymentId = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl).DeploymentId;

            var stmt     = epService.EPAdministrator.GetStatement("s0");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

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

            SendPoint(epService, "P1", 55, 45);
            AssertRectanglesManyRow(epService, listener, BOXES, null, "P1", null, null, "P1");

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

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

            epService.EPRuntime.ExecuteQuery("delete from MyPointTable where my_x = 55 and my_y = 45");
            SendPoint(epService, "P4", 45, 55);
            AssertRectanglesManyRow(epService, listener, BOXES, "P2", null, "P4", "P3", "P2,P3,P4");

            epService.EPAdministrator.DeploymentAdmin.Undeploy(deploymentId);
        }
示例#3
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindow#keepall as (p0 string, p1 int);", path);
                env.CompileDeploy("create unique index MyIndex on MyWindow(p0);", path);
                env.CompileDeploy(
                    INDEX_CALLBACK_HOOK +
                    "@Name('s0') on SupportBean_S0 as S0 select p0, p1 from MyWindow as win where win.p0 = S0.P00;",
                    path);
                env.AddListener("s0");

                SupportQueryPlanIndexHook.AssertOnExprTableAndReset(
                    "MyIndex",
                    "unique hash={p0(string)} btree={} advanced={}");

                env.CompileExecuteFAF("insert into MyWindow select 'a' as p0, 1 as p1", path);

                env.SendEventBean(new SupportBean_S0(1, "a"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"p0", "p1"},
                    new object[] {"a", 1});

                env.UndeployAll();
            }
示例#4
0
        private void RunAssertionEventIndexExpression(EPServiceProvider epService)
        {
            epService.EPAdministrator.CreateEPL("create table MyTable(id string primary key, tx double, ty double)");
            epService.EPRuntime.ExecuteQuery("insert into MyTable values ('P1', 50, 30)");
            epService.EPRuntime.ExecuteQuery("insert into MyTable values ('P2', 50, 28)");
            epService.EPRuntime.ExecuteQuery("insert into MyTable values ('P3', 50, 30)");
            epService.EPRuntime.ExecuteQuery("insert into MyTable values ('P4', 49, 29)");
            epService.EPAdministrator.CreateEPL("create index MyIdxWithExpr on MyTable( (tx*10, ty*10) pointregionquadtree(0, 0, 1000, 1000))");

            var eplOne       = IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "on SupportSpatialAABB select tbl.id as c0 from MyTable as tbl where point(tx, ty).inside(rectangle(x, y, width, height))";
            var statementOne = epService.EPAdministrator.CreateEPL(eplOne);
            var listener     = new SupportUpdateListener();

            statementOne.Events += listener.Update;
            SupportQueryPlanIndexHook.AssertOnExprTableAndReset(null, null);
            AssertRectanglesManyRow(epService, listener, BOXES, "P4", "P1,P2,P3", null, null, "P1,P2,P3,P4");
            statementOne.Dispose();

            var eplTwo       = IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "on SupportSpatialAABB select tbl.id as c0 from MyTable as tbl where point(tx*10, tbl.ty*10).inside(rectangle(x, y, width, height))";
            var statementTwo = epService.EPAdministrator.CreateEPL(eplTwo);

            statementTwo.Events += listener.Update;
            SupportQueryPlanIndexHook.AssertOnExprTableAndReset("MyIdxWithExpr", "non-unique hash={} btree={} advanced={pointregionquadtree(tx*10,ty*10)}");
            AssertRectanglesManyRow(epService, listener, BOXES, null, null, null, null, null);
            AssertRectanglesManyRow(epService, listener, Collections.SingletonList(new BoundingBox(500, 300, 501, 301)), "P1,P3");
            statementTwo.Dispose();

            epService.EPAdministrator.DestroyAllStatements();
        }
示例#5
0
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('win') create window MyRectWindow#keepall as (Id string, rx double, ry double, rw double, rh double);\n" +
                    "@Name('insert') insert into MyRectWindow select Id, X as rx, Y as ry, Width as rw, Height as rh from SupportSpatialEventRectangle;\n" +
                    "@Name('Idx') create unique index Idx on MyRectWindow( (rx, ry, rw, rh) mxcifquadtree(0, 0, 100, 100));\n" +
                    IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                    "@Name('out') on SupportSpatialAABB select mpw.Id as c0 from MyRectWindow as mpw where rectangle(rx, ry, rw, rh).intersects(rectangle(X, Y, Width, Height));\n";
                env.CompileDeploy(epl).AddListener("out");

                SupportQueryPlanIndexHook.AssertOnExprTableAndReset(
                    "Idx",
                    "unique hash={} btree={} advanced={mxcifquadtree(rx,ry,rw,rh)}");

                SendEventRectangle(env, "P1", 10, 15, 1, 2);
                try {
                    SendEventRectangle(env, "P1", 10, 15, 1, 2);
                    Assert.Fail();
                }
                catch (Exception ex) { // we have a handler
                    SupportMessageAssertUtil.AssertMessage(
                        ex,
                        "Unexpected exception in statement 'win': Unique index violation, index 'Idx' is a unique index and key '(10.0d,15.0d,1.0d,2.0d)' already exists");
                }

                env.UndeployAll();
            }
示例#6
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeployWBusPublicType("create schema Geofence(x double, y double, vin string)", path);

                env.CompileDeploy(
                    "create table Regions(regionId string primary key, rx double, ry double, rwidth double, rheight double)",
                    path);
                env.CompileDeploy(
                    "create index RectangleIndex on Regions((rx, ry, rwidth, rheight) mxcifquadtree(0, 0, 10, 12))",
                    path);
                env.CompileDeploy(
                    "@Name('s0') " +
                    IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                    "on Geofence as vin insert into VINWithRegion select regionId, vin from Regions where rectangle(rx, ry, rwidth, rheight).intersects(rectangle(vin.x, vin.y, 0, 0))",
                    path);
                env.AddListener("s0");

                SupportQueryPlanIndexHook.AssertOnExprTableAndReset(
                    "RectangleIndex",
                    "non-unique hash={} btree={} advanced={mxcifquadtree(rx,ry,rwidth,rheight)}");

                env.CompileExecuteFAF("insert into Regions values ('R1', 2, 2, 5, 5)", path);
                env.SendEventMap(CollectionUtil.PopulateNameValueMap("x", 3d, "y", 3d, "vin", "V1"), "Geofence");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"vin", "regionId"},
                    new object[] {"V1", "R1"});

                env.UndeployAll();
            }
示例#7
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();
        }
示例#8
0
        private void RunAssertionEventIndexOnTriggerNWInsertRemove(EPServiceProvider epService, bool soda)
        {
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "create window MyWindow#length(5) as select * from SupportSpatialEventRectangle");
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "create index MyIndex on MyWindow((x,y,width,height) mxcifquadtree(0,0,100,100))");
            SupportModelHelper.CreateByCompileOrParse(epService, soda, "insert into MyWindow select * from SupportSpatialEventRectangle");

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

            stmt.Events += listener.Update;

            SupportQueryPlanIndexHook.AssertOnExprTableAndReset("MyIndex", "non-unique hash={} btree={} advanced={mxcifquadtree(x,y,width,height)}");

            SendEventRectangle(epService, "R1", 10, 40, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R1", null, null, null, null);

            SendEventRectangle(epService, "R2", 80, 80, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R1", null, null, "R2", null);

            SendEventRectangle(epService, "R3", 10, 40, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R1,R3", null, null, "R2", null);

            SendEventRectangle(epService, "R4", 60, 40, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R1,R3", "R4", null, "R2", "R4");

            SendEventRectangle(epService, "R5", 20, 75, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R1,R3", "R4", "R5", "R2", "R4");

            SendEventRectangle(epService, "R6", 50, 50, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R3,R6", "R4,R6", "R5,R6", "R2,R6", "R4,R6");

            SendEventRectangle(epService, "R7", 0, 0, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R3,R6,R7", "R4,R6", "R5,R6", "R6", "R4,R6");

            SendEventRectangle(epService, "R8", 99.999, 0, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R6,R7", "R4,R6,R8", "R5,R6", "R6", "R4,R6");

            SendEventRectangle(epService, "R9", 0, 99.999, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R6,R7", "R6,R8", "R5,R6,R9", "R6", "R6");

            SendEventRectangle(epService, "R10", 99.999, 99.999, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R6,R7", "R6,R8", "R6,R9", "R6,R10", "R6");

            SendEventRectangle(epService, "R11", 0, 0, 1, 1);
            AssertRectanglesManyRow(epService, listener, BOXES, "R7,R11", "R8", "R9", "R10", null);

            epService.EPAdministrator.DestroyAllStatements();
        }
示例#9
0
        private void RunIndexUnusedConstantsOnly(EPServiceProvider epService)
        {
            var epl = IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "@Name('out') on SupportSpatialAABB as aabb select points.id as c0 " +
                      "from MyWindow as points where point(0, 0).inside(rectangle(x,y,width,height))";
            var stmt     = epService.EPAdministrator.CreateEPL(epl);
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SupportQueryPlanIndexHook.AssertOnExprTableAndReset(null, null);

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

            stmt.Dispose();
        }
示例#10
0
        private void RunAssertionEventIndexUnique(EPServiceProvider epService)
        {
            var epl = "@Name('win') create window MyRectWindow#keepall as (id string, rx double, ry double, rw double, rh double);\n" +
                      "@Name('insert') insert into MyRectWindow select id, x as rx, y as ry, width as rw, height as rh from SupportSpatialEventRectangle;\n" +
                      "@Name('idx') create unique index Idx on MyRectWindow( (rx, ry, rw, rh) mxcifquadtree(0, 0, 100, 100));\n" +
                      IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "@Name('out') on SupportSpatialAABB select mpw.id as c0 from MyRectWindow as mpw where rectangle(rx, ry, rw, rh).intersects(rectangle(x, y, width, height));\n";
            var deploymentId = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl).DeploymentId;
            var listener     = new SupportUpdateListener();

            epService.EPAdministrator.GetStatement("out").Events += listener.Update;

            SupportQueryPlanIndexHook.AssertOnExprTableAndReset("Idx", "unique hash={} btree={} advanced={mxcifquadtree(rx,ry,rw,rh)}");

            SendEventRectangle(epService, "P1", 10, 15, 1, 2);
            try {
                SendEventRectangle(epService, "P1", 10, 15, 1, 2);
                Assert.Fail();
            } catch (Exception ex) { // we have a handler
                SupportMessageAssertUtil.AssertMessage(ex,
                                                       "Unexpected exception in statement 'win': Unique index violation, index 'Idx' is a unique index and key '(10,15,1,2)' already exists");
            }

            epService.EPAdministrator.DeploymentAdmin.Undeploy(deploymentId);
        }
示例#11
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    soda,
                    "create window MyWindow#length(5) as select * from SupportSpatialEventRectangle",
                    path);
                env.CompileDeploy(
                    soda,
                    "create index MyIndex on MyWindow((X,Y,Width,Height) mxcifquadtree(0,0,100,100))",
                    path);
                env.CompileDeploy(soda, "insert into MyWindow select * from SupportSpatialEventRectangle", path);

                var epl = "@Name('s0') " +
                          IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                          " on SupportSpatialAABB as aabb " +
                          "select rects.Id as c0 from MyWindow as rects where rectangle(rects.X,rects.Y,rects.Width,rects.Height).intersects(rectangle(aabb.X,aabb.Y,aabb.Width,aabb.Height))";
                env.CompileDeploy(soda, epl, path).AddListener("s0");

                SupportQueryPlanIndexHook.AssertOnExprTableAndReset(
                    "MyIndex",
                    "non-unique hash={} btree={} advanced={mxcifquadtree(X,Y,Width,Height)}");

                SendEventRectangle(env, "R1", 10, 40, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R1", null, null, null, null);

                SendEventRectangle(env, "R2", 80, 80, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R1", null, null, "R2", null);

                env.Milestone(0);

                SendEventRectangle(env, "R3", 10, 40, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R1,R3", null, null, "R2", null);

                env.Milestone(1);

                SendEventRectangle(env, "R4", 60, 40, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R1,R3", "R4", null, "R2", "R4");

                SendEventRectangle(env, "R5", 20, 75, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R1,R3", "R4", "R5", "R2", "R4");

                env.Milestone(2);

                SendEventRectangle(env, "R6", 50, 50, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R3,R6", "R4,R6", "R5,R6", "R2,R6", "R4,R6");

                SendEventRectangle(env, "R7", 0, 0, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R3,R6,R7", "R4,R6", "R5,R6", "R6", "R4,R6");

                env.Milestone(3);

                SendEventRectangle(env, "R8", 99.999, 0, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R6,R7", "R4,R6,R8", "R5,R6", "R6", "R4,R6");

                SendEventRectangle(env, "R9", 0, 99.999, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R6,R7", "R6,R8", "R5,R6,R9", "R6", "R6");

                env.Milestone(4);

                SendEventRectangle(env, "R10", 99.999, 99.999, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R6,R7", "R6,R8", "R6,R9", "R6,R10", "R6");

                SendEventRectangle(env, "R11", 0, 0, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("s0"), BOXES, "R7,R11", "R8", "R9", "R10", null);

                env.UndeployAll();
            }