Ejemplo n.º 1
0
 public void Run(RegressionEnvironment env)
 {
     SupportQueryPlanIndexHook.Reset();
     var epl = "@Name('s0') " +
               INDEX_CALLBACK_HOOK +
               "select S1.Id as c0," +
               "(select * from SupportBean_S0#keepall as S0 " +
               "  where S0.P00 in (S1.P10, SupportBean_S1.P11) and S0.P01 in (S1.P12, SupportBean_S1.P13))" +
               ".selectFrom(a->SupportBean_S0.Id) as c1 " +
               " from SupportBean_S1 as S1";
     env.CompileDeploy(epl).AddListener("s0");
     var subquery = SupportQueryPlanIndexHook.AssertSubqueryAndReset();
     Assert.AreEqual(typeof(SubordInKeywordSingleTableLookupStrategyFactoryForge).Name, subquery.TableLookupStrategy);
     // single row tests
     env.SendEventBean(new SupportBean_S0(100, "a", "c"));
     env.SendEventBean(new SupportBean_S1(1, "a1", "b", "c", "d"));
     AssertSubqueryC0C1(env, 1, null);
     env.SendEventBean(new SupportBean_S1(2, "a", "b", "x", "d"));
     AssertSubqueryC0C1(env, 2, null);
     env.SendEventBean(new SupportBean_S1(3, "a", "b", "c", "d"));
     AssertSubqueryC0C1(env, 3, new int?[] {100});
     env.SendEventBean(new SupportBean_S1(4, "x", "a", "x", "c"));
     AssertSubqueryC0C1(env, 4, new int?[] {100});
     // 2-rows available tests
     env.SendEventBean(new SupportBean_S0(101, "a", "d"));
     env.SendEventBean(new SupportBean_S1(10, "a1", "b", "c", "d"));
     AssertSubqueryC0C1(env, 10, null);
     env.SendEventBean(new SupportBean_S1(11, "a", "b", "x", "c1"));
     AssertSubqueryC0C1(env, 11, null);
     env.SendEventBean(new SupportBean_S1(12, "a", "b", "c", "d"));
     AssertSubqueryC0C1(env, 12, new int?[] {100, 101});
     env.SendEventBean(new SupportBean_S1(13, "x", "a", "x", "c"));
     AssertSubqueryC0C1(env, 13, new int?[] {100});
     env.SendEventBean(new SupportBean_S1(14, "x", "a", "d", "x"));
     AssertSubqueryC0C1(env, 14, new int?[] {101});
     // 3-rows available tests
     env.SendEventBean(new SupportBean_S0(102, "b", "c"));
     env.SendEventBean(new SupportBean_S1(20, "a1", "b", "c1", "d"));
     AssertSubqueryC0C1(env, 20, null);
     env.SendEventBean(new SupportBean_S1(21, "a", "b", "x", "c1"));
     AssertSubqueryC0C1(env, 21, null);
     env.SendEventBean(new SupportBean_S1(22, "a", "b", "c", "d"));
     AssertSubqueryC0C1(env, 22, new int?[] {100, 101, 102});
     env.SendEventBean(new SupportBean_S1(23, "b", "a", "x", "c"));
     AssertSubqueryC0C1(env, 23, new int?[] {100, 102});
     env.SendEventBean(new SupportBean_S1(24, "b", "a", "d", "c"));
     AssertSubqueryC0C1(env, 24, new int?[] {100, 101, 102});
     env.SendEventBean(new SupportBean_S1(25, "b", "x", "x", "c"));
     AssertSubqueryC0C1(env, 25, new int?[] {102});
     env.UndeployAll();
     // test coercion absence - types the same
     var eplCoercion = INDEX_CALLBACK_HOOK +
                       "select *," +
                       "(select * from SupportBean#keepall as sb where sb.LongPrimitive in (S0.Id)) from SupportBean_S0 as S0";
     env.CompileDeploy(eplCoercion);
     var subqueryCoercion = SupportQueryPlanIndexHook.AssertSubqueryAndReset();
     Assert.AreEqual(typeof(SubordFullTableScanLookupStrategyFactoryForge).Name, subqueryCoercion.TableLookupStrategy);
     env.UndeployAll();
 }
Ejemplo n.º 2
0
        private void RunAssertionEventIndexSubqNamedWindowIndexShare(EPServiceProvider epService)
        {
            var epl = "@Hint('enable_window_subquery_indexshare') create window MyWindow#length(5) as select * from SupportSpatialPoint;\n" +
                      "create index MyIndex on MyWindow((px,py) pointregionquadtree(0,0,100,100));\n" +
                      "insert into MyWindow select * from SupportSpatialPoint;\n" +
                      IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                      "@Name('out') select (select id from MyWindow as mw where point(mw.px,mw.py).inside(rectangle(aabb.x,aabb.y,aabb.width,aabb.height))).aggregate('', \n" +
                      "  (result, item) => result || (case when result='' then '' else ',' end) || item) as c0 from SupportSpatialAABB aabb";
            var deploymentResult = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl);
            var listener         = new SupportUpdateListener();

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

            var subquery = SupportQueryPlanIndexHook.AssertSubqueryAndReset();

            Assert.AreEqual("non-unique hash={} btree={} advanced={pointregionquadtree(px,py)}", subquery.Tables[0].IndexDesc);
            Assert.AreEqual("MyIndex", subquery.Tables[0].IndexName);

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

            epService.EPAdministrator.DeploymentAdmin.Undeploy(deploymentResult.DeploymentId);
        }
Ejemplo n.º 3
0
        public void TestSingleIdxSubquery()
        {
            SupportQueryPlanIndexHook.Reset();
            var epl = INDEX_CALLBACK_HOOK + "select s1.id as c0," +
                      "(select * from S0.win:keepall() as s0 " +
                      "  where s0.p00 in (s1.p10, s1.p11) and s0.p01 in (s1.p12, s1.p13))" +
                      ".selectFrom(a=>S0.id) as c1 " +
                      " from S1 as s1";
            var stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.AddListener(_listener);

            var subquery = SupportQueryPlanIndexHook.AssertSubqueryAndReset();

            Assert.AreEqual(typeof(SubordInKeywordSingleTableLookupStrategyFactory).Name, subquery.TableLookupStrategy);

            // single row tests
            _epService.EPRuntime.SendEvent(new SupportBean_S0(100, "a", "c"));

            _epService.EPRuntime.SendEvent(new SupportBean_S1(1, "a1", "b", "c", "d"));
            AssertSubqueryC0C1(1, null);

            _epService.EPRuntime.SendEvent(new SupportBean_S1(2, "a", "b", "x", "d"));
            AssertSubqueryC0C1(2, null);

            _epService.EPRuntime.SendEvent(new SupportBean_S1(3, "a", "b", "c", "d"));
            AssertSubqueryC0C1(3, new int?[] { 100 });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(4, "x", "a", "x", "c"));
            AssertSubqueryC0C1(4, new int?[] { 100 });

            // 2-rows available tests
            _epService.EPRuntime.SendEvent(new SupportBean_S0(101, "a", "d"));

            _epService.EPRuntime.SendEvent(new SupportBean_S1(10, "a1", "b", "c", "d"));
            AssertSubqueryC0C1(10, null);

            _epService.EPRuntime.SendEvent(new SupportBean_S1(11, "a", "b", "x", "c1"));
            AssertSubqueryC0C1(11, null);

            _epService.EPRuntime.SendEvent(new SupportBean_S1(12, "a", "b", "c", "d"));
            AssertSubqueryC0C1(12, new int?[] { 100, 101 });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(13, "x", "a", "x", "c"));
            AssertSubqueryC0C1(13, new int?[] { 100 });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(14, "x", "a", "d", "x"));
            AssertSubqueryC0C1(14, new int?[] { 101 });

            // 3-rows available tests
            _epService.EPRuntime.SendEvent(new SupportBean_S0(102, "b", "c"));

            _epService.EPRuntime.SendEvent(new SupportBean_S1(20, "a1", "b", "c1", "d"));
            AssertSubqueryC0C1(20, null);

            _epService.EPRuntime.SendEvent(new SupportBean_S1(21, "a", "b", "x", "c1"));
            AssertSubqueryC0C1(21, null);

            _epService.EPRuntime.SendEvent(new SupportBean_S1(22, "a", "b", "c", "d"));
            AssertSubqueryC0C1(22, new int?[] { 100, 101, 102 });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(23, "b", "a", "x", "c"));
            AssertSubqueryC0C1(23, new int?[] { 100, 102 });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(24, "b", "a", "d", "c"));
            AssertSubqueryC0C1(24, new int?[] { 100, 101, 102 });

            _epService.EPRuntime.SendEvent(new SupportBean_S1(25, "b", "x", "x", "c"));
            AssertSubqueryC0C1(25, new int?[] { 102 });

            // test coercion absence - types the same
            var eplCoercion = INDEX_CALLBACK_HOOK + "select *," +
                              "(select * from SupportBean.win:keepall() as sb where sb.LongPrimitive in (s0.id)) from S0 as s0";

            _epService.EPAdministrator.CreateEPL(eplCoercion);
            var subqueryCoercion = SupportQueryPlanIndexHook.AssertSubqueryAndReset();

            Assert.AreEqual(typeof(SubordFullTableScanLookupStrategyFactory).Name, subqueryCoercion.TableLookupStrategy);
        }
Ejemplo n.º 4
0
        private void RunAssertionSingleIdxSubquery(EPServiceProvider epService)
        {
            SupportQueryPlanIndexHook.Reset();
            var epl = INDEX_CALLBACK_HOOK + "select s1.Id as c0," +
                      "(select * from S0#keepall as s0 " +
                      "  where s0.P00 in (s1.P10, s1.P11) and s0.P01 in (s1.P12, s1.P13))" +
                      ".selectFrom(a=>S0.Id) as c1 " +
                      " from S1 as s1";
            var stmt = epService.EPAdministrator.CreateEPL(epl);
            var listener = new SupportUpdateListener();
            stmt.Events += listener.Update;

            var subquery = SupportQueryPlanIndexHook.AssertSubqueryAndReset();
            Assert.AreEqual(typeof(SubordInKeywordSingleTableLookupStrategyFactory).Name, subquery.TableLookupStrategy);

            // single row tests
            epService.EPRuntime.SendEvent(new SupportBean_S0(100, "a", "c"));

            epService.EPRuntime.SendEvent(new SupportBean_S1(1, "a1", "b", "c", "d"));
            AssertSubqueryC0C1(listener, 1, null);

            epService.EPRuntime.SendEvent(new SupportBean_S1(2, "a", "b", "x", "d"));
            AssertSubqueryC0C1(listener, 2, null);

            epService.EPRuntime.SendEvent(new SupportBean_S1(3, "a", "b", "c", "d"));
            AssertSubqueryC0C1(listener, 3, new int?[] {100});

            epService.EPRuntime.SendEvent(new SupportBean_S1(4, "x", "a", "x", "c"));
            AssertSubqueryC0C1(listener, 4, new int?[] {100});

            // 2-rows available tests
            epService.EPRuntime.SendEvent(new SupportBean_S0(101, "a", "d"));

            epService.EPRuntime.SendEvent(new SupportBean_S1(10, "a1", "b", "c", "d"));
            AssertSubqueryC0C1(listener, 10, null);

            epService.EPRuntime.SendEvent(new SupportBean_S1(11, "a", "b", "x", "c1"));
            AssertSubqueryC0C1(listener, 11, null);

            epService.EPRuntime.SendEvent(new SupportBean_S1(12, "a", "b", "c", "d"));
            AssertSubqueryC0C1(listener, 12, new int?[] {100, 101});

            epService.EPRuntime.SendEvent(new SupportBean_S1(13, "x", "a", "x", "c"));
            AssertSubqueryC0C1(listener, 13, new int?[] {100});

            epService.EPRuntime.SendEvent(new SupportBean_S1(14, "x", "a", "d", "x"));
            AssertSubqueryC0C1(listener, 14, new int?[] {101});

            // 3-rows available tests
            epService.EPRuntime.SendEvent(new SupportBean_S0(102, "b", "c"));

            epService.EPRuntime.SendEvent(new SupportBean_S1(20, "a1", "b", "c1", "d"));
            AssertSubqueryC0C1(listener, 20, null);

            epService.EPRuntime.SendEvent(new SupportBean_S1(21, "a", "b", "x", "c1"));
            AssertSubqueryC0C1(listener, 21, null);

            epService.EPRuntime.SendEvent(new SupportBean_S1(22, "a", "b", "c", "d"));
            AssertSubqueryC0C1(listener, 22, new int?[] {100, 101, 102});

            epService.EPRuntime.SendEvent(new SupportBean_S1(23, "b", "a", "x", "c"));
            AssertSubqueryC0C1(listener, 23, new int?[] {100, 102});

            epService.EPRuntime.SendEvent(new SupportBean_S1(24, "b", "a", "d", "c"));
            AssertSubqueryC0C1(listener, 24, new int?[] {100, 101, 102});

            epService.EPRuntime.SendEvent(new SupportBean_S1(25, "b", "x", "x", "c"));
            AssertSubqueryC0C1(listener, 25, new int?[] {102});

            stmt.Dispose();

            // test coercion absence - types the same
            var eplCoercion = INDEX_CALLBACK_HOOK + "select *," +
                              "(select * from SupportBean#keepall as sb where sb.LongPrimitive in (s0.Id)) from S0 as s0";
            stmt = epService.EPAdministrator.CreateEPL(eplCoercion);
            var subqueryCoercion = SupportQueryPlanIndexHook.AssertSubqueryAndReset();
            Assert.AreEqual(
                typeof(SubordFullTableScanLookupStrategyFactory).Name, subqueryCoercion.TableLookupStrategy);
            stmt.Dispose();
        }