Esempio n. 1
0
        private void RunAssertionMultipleIndexHints(bool namedWindow)
        {
            var eplCreate = namedWindow ?
                            "@Hint('enable_window_subquery_indexshare') create window MyInfra#keepall as select * from SSB1" :
                            "create table MyInfra(S1 String primary key, I1 int  primary key, D1 double primary key, L1 long primary key)";

            _epService.EPAdministrator.CreateEPL(eplCreate);
            _epService.EPAdministrator.CreateEPL("create unique index I1 on MyInfra (S1)");
            _epService.EPAdministrator.CreateEPL("create unique index I2 on MyInfra (I1)");

            _epService.EPAdministrator.CreateEPL(INDEX_CALLBACK_HOOK +
                                                 "@Hint('index(subquery(1), I1, bust)')\n" +
                                                 "@Hint('index(subquery(0), I2, bust)')\n" +
                                                 "select " +
                                                 "(select * from MyInfra where S1 = ssb2.S2 and I1 = ssb2.I2) as sub1," +
                                                 "(select * from MyInfra where I1 = ssb2.I2 and S1 = ssb2.S2) as sub2 " +
                                                 "from SSB2 ssb2");
            var subqueries = SupportQueryPlanIndexHook.GetAndResetSubqueries();

            Collections.SortInPlace(subqueries, (o1, o2) => o1.Tables[0].IndexName.CompareTo(o2.Tables[0].IndexName));
            SupportQueryPlanIndexHook.AssertSubquery(subqueries[0], 1, "I1", "unique hash={S1(string)} btree={}");
            SupportQueryPlanIndexHook.AssertSubquery(subqueries[1], 0, "I2", "unique hash={I1(int)} btree={}");

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false);
        }
        private void RunAssertionDocSample(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType(typeof(AEvent));
            epService.EPAdministrator.Configuration.AddEventType(typeof(BEvent));

            var hints = new string[] {
                "@Hint('Exclude_plan(true)')",
                "@Hint('Exclude_plan(opname=\"equals\")')",
                "@Hint('Exclude_plan(opname=\"equals\" and from_streamname=\"a\")')",
                "@Hint('Exclude_plan(opname=\"equals\" and from_streamname=\"b\")')",
                "@Hint('Exclude_plan(exprs[0]=\"aprop\")')"
            };

            foreach (string hint in hints)
            {
                epService.EPAdministrator.CreateEPL("@Audit " + hint +
                                                    "select * from AEvent#keepall as a, BEvent#keepall as b where aprop = bprop");
            }

            // test subquery
            SupportQueryPlanIndexHook.Reset();
            epService.EPAdministrator.CreateEPL(INDEX_CALLBACK_HOOK + "@Hint('Exclude_plan(true)') select (select * from S0#unique(p00) as s0 where s1.p10 = p00) from S1 as s1");
            QueryPlanIndexDescSubquery subq = SupportQueryPlanIndexHook.GetAndResetSubqueries()[0];

            Assert.AreEqual(typeof(SubordFullTableScanLookupStrategyFactory).Name, subq.TableLookupStrategy);

            // test named window
            epService.EPAdministrator.CreateEPL("create window S0Window#keepall as S0");
            epService.EPAdministrator.CreateEPL(INDEX_CALLBACK_HOOK + "@Hint('Exclude_plan(true)') on S1 as s1 select * from S0Window as s0 where s1.p10 = s0.p00");
            QueryPlanIndexDescOnExpr onExpr = SupportQueryPlanIndexHook.GetAndResetOnExpr();

            Assert.AreEqual(typeof(SubordWMatchExprLookupStrategyFactoryAllFiltered).Name, onExpr.StrategyName);

            epService.EPAdministrator.DestroyAllStatements();
        }
Esempio n. 3
0
        private void RunAssertionMultipleIndexHints(EPServiceProvider epService, bool namedWindow)
        {
            string eplCreate = namedWindow ?
                               "@Hint('enable_window_subquery_indexshare') create window MyInfraMIH#keepall as select * from SSB1" :
                               "create table MyInfraMIH(s1 string primary key, i1 int  primary key, d1 double primary key, l1 long primary key)";

            epService.EPAdministrator.CreateEPL(eplCreate);
            epService.EPAdministrator.CreateEPL("create unique index I1 on MyInfraMIH (s1)");
            epService.EPAdministrator.CreateEPL("create unique index I2 on MyInfraMIH (i1)");

            epService.EPAdministrator.CreateEPL(INDEX_CALLBACK_HOOK +
                                                "@Hint('index(subquery(1), I1, bust)')\n" +
                                                "@Hint('index(subquery(0), I2, bust)')\n" +
                                                "select " +
                                                "(select * from MyInfraMIH where s1 = ssb2.s2 and i1 = ssb2.i2) as sub1," +
                                                "(select * from MyInfraMIH where i1 = ssb2.i2 and s1 = ssb2.s2) as sub2 " +
                                                "from SSB2 ssb2");
            List <QueryPlanIndexDescSubquery> subqueries = SupportQueryPlanIndexHook.GetAndResetSubqueries();

            subqueries.Sort((o1, o2) => o1.Tables[0].IndexName.CompareTo(o2.Tables[0].IndexName));
            SupportQueryPlanIndexHook.AssertSubquery(subqueries[0], 1, "I1", "unique hash={s1(string)} btree={} advanced={}");
            SupportQueryPlanIndexHook.AssertSubquery(subqueries[1], 0, "I2", "unique hash={i1(int)} btree={} advanced={}");

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("MyInfraMIH", false);
        }
Esempio n. 4
0
            public void Run(RegressionEnvironment env)
            {
                var schema =
                    "create schema AEvent as " +
                    typeof(AEvent).MaskTypeName() +
                    ";\n" +
                    "create schema BEvent as " +
                    typeof(BEvent).MaskTypeName() +
                    ";\n";
                var path = new RegressionPath();
                env.CompileDeploy(schema, path);

                string[] hints = {
                    "@Hint('exclude_plan(true)')",
                    "@Hint('exclude_plan(opname=\"equals\")')",
                    "@Hint('exclude_plan(opname=\"equals\" and from_streamname=\"a\")')",
                    "@Hint('exclude_plan(opname=\"equals\" and from_streamname=\"b\")')",
                    "@Hint('exclude_plan(exprs[0]=\"aprop\")')"
                };
                foreach (var hint in hints) {
                    env.CompileDeploy(
                        "@Audit " +
                        hint +
                        "select * from AEvent#keepall as a, BEvent#keepall as b where aprop = bprop",
                        path);
                }

                // test subquery
                SupportQueryPlanIndexHook.Reset();
                env.CompileDeploy(
                    INDEX_CALLBACK_HOOK +
                    "@Hint('exclude_plan(true)') select (select * from SupportBean_S0#unique(P00) as S0 where S1.P10 = P00) from SupportBean_S1 as S1",
                    path);
                var subq = SupportQueryPlanIndexHook.GetAndResetSubqueries()[0];
                Assert.AreEqual(typeof(SubordFullTableScanLookupStrategyFactoryForge).Name, subq.TableLookupStrategy);

                // test named window
                env.CompileDeploy("create window S0Window#keepall as SupportBean_S0", path);
                env.CompileDeploy(
                    INDEX_CALLBACK_HOOK +
                    "@Hint('exclude_plan(true)') on SupportBean_S1 as S1 select * from S0Window as S0 where S1.P10 = S0.P00",
                    path);
                var onExpr = SupportQueryPlanIndexHook.GetAndResetOnExpr();
                Assert.AreEqual(typeof(SubordWMatchExprLookupStrategyAllFilteredForge).Name, onExpr.StrategyName);

                env.UndeployAll();
            }
Esempio n. 5
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var eplCreate = namedWindow
                    ? "@Hint('enable_window_subquery_indexshare') create window MyInfraMIH#keepall as select * from SupportSimpleBeanOne"
                    : "create table MyInfraMIH(S1 String primary key, I1 int primary key, D1 double primary key, L1 long primary key)";
                env.CompileDeploy(eplCreate, path);
                env.CompileDeploy("create unique index I1 on MyInfraMIH (S1)", path);
                env.CompileDeploy("create unique index I2 on MyInfraMIH (I1)", path);

                env.CompileDeploy(
                    INDEX_CALLBACK_HOOK +
                    "@Hint('index(subquery(1), I1, bust)')\n" +
                    "@Hint('index(subquery(0), I2, bust)')\n" +
                    "select " +
                    "(select * from MyInfraMIH where S1 = ssb2.S2 and I1 = ssb2.I2) as sub1," +
                    "(select * from MyInfraMIH where I1 = ssb2.I2 and S1 = ssb2.S2) as sub2 " +
                    "from SupportSimpleBeanTwo ssb2",
                    path);
                var subqueries = SupportQueryPlanIndexHook.GetAndResetSubqueries();
                subqueries.SortInPlace(
                    (
                        o1,
                        o2) => {
                        return o1.Tables[0].IndexName.CompareTo(o2.Tables[0].IndexName);
                    });
                SupportQueryPlanIndexHook.AssertSubquery(
                    subqueries[0],
                    1,
                    "I1",
                    "unique hash={S1(string)} btree={} advanced={}");
                SupportQueryPlanIndexHook.AssertSubquery(
                    subqueries[1],
                    0,
                    "I2",
                    "unique hash={I1(int)} btree={} advanced={}");

                env.UndeployAll();
            }