private void RunAssertionQueryPlan2Stream(EPServiceProvider epService)
        {
            var epl = "select * from S0 as s0 unidirectional, S1#keepall ";
            var fullTableScan = SupportQueryPlanBuilder.Start(2)
                .SetIndexFullTableScan(1, "a")
                .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("a")))
                .Get();

            // 2-stream unidirectional joins
            TryAssertion(epService, epl, fullTableScan);

            var planEquals = SupportQueryPlanBuilder.Start(2)
                .AddIndexHashSingleNonUnique(1, "a", "P10")
                .SetLookupPlanInner(
                    0,
                    new IndexedTableLookupPlanSingle(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeKeyed("P00")))
                .Get();
            TryAssertion(epService, epl + "where P00 = P10", planEquals);
            TryAssertion(epService, epl + "where P00 = P10 and P00 in (P11, P12, P13)", planEquals);

            var planInMultiInner = SupportQueryPlanBuilder.Start(2)
                .AddIndexHashSingleNonUnique(1, "a", "P11")
                .AddIndexHashSingleNonUnique(1, "b", "P12")
                .SetLookupPlanInner(
                    0,
                    new InKeywordTableLookupPlanMultiIdx(
                        0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("P00")))
                .Get();
            TryAssertion(epService, epl + "where P00 in (P11, P12)", planInMultiInner);
            TryAssertion(epService, epl + "where P00 = P11 or P00 = P12", planInMultiInner);

            var planInMultiOuter = SupportQueryPlanBuilder.Start(planInMultiInner)
                .SetLookupPlanOuter(
                    0,
                    new InKeywordTableLookupPlanMultiIdx(
                        0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("P00")))
                .Get();
            var eplOuterJoin = "select * from S0 as s0 unidirectional full outer join S1#keepall ";
            TryAssertion(epService, eplOuterJoin + "where P00 in (P11, P12)", planInMultiOuter);

            var planInMultiWConst = SupportQueryPlanBuilder.Start(2)
                .AddIndexHashSingleNonUnique(1, "a", "P11")
                .AddIndexHashSingleNonUnique(1, "b", "P12")
                .SetLookupPlanInner(
                    0,
                    new InKeywordTableLookupPlanMultiIdx(
                        0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeConstExprNode("A")))
                .Get();
            TryAssertion(epService, epl + "where 'A' in (P11, P12)", planInMultiWConst);
            TryAssertion(epService, epl + "where 'A' = P11 or 'A' = P12", planInMultiWConst);

            var planInMultiWAddConst = SupportQueryPlanBuilder.Start(2)
                .AddIndexHashSingleNonUnique(1, "a", "P12")
                .SetLookupPlanInner(
                    0,
                    new InKeywordTableLookupPlanMultiIdx(
                        0, 1, GetIndexKeys("a"), SupportExprNodeFactory.MakeConstExprNode("A")))
                .Get();
            TryAssertion(epService, epl + "where 'A' in ('B', P12)", planInMultiWAddConst);
            TryAssertion(epService, epl + "where 'A' in ('B', 'C')", fullTableScan);

            var planInSingle = SupportQueryPlanBuilder.Start(2)
                .AddIndexHashSingleNonUnique(1, "a", "P10")
                .SetLookupPlanInner(
                    0,
                    new InKeywordTableLookupPlanSingleIdx(
                        0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeIdentExprNodes("P00", "P01")))
                .Get();
            TryAssertion(epService, epl + "where P10 in (P00, P01)", planInSingle);

            var planInSingleWConst = SupportQueryPlanBuilder.Start(2)
                .AddIndexHashSingleNonUnique(1, "a", "P10")
                .SetLookupPlanInner(
                    0,
                    new InKeywordTableLookupPlanSingleIdx(
                        0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndIdentNode("A", "P01")))
                .Get();
            TryAssertion(epService, epl + "where P10 in ('A', P01)", planInSingleWConst);

            var planInSingleJustConst = SupportQueryPlanBuilder.Start(2)
                .AddIndexHashSingleNonUnique(1, "a", "P10")
                .SetLookupPlanInner(
                    0,
                    new InKeywordTableLookupPlanSingleIdx(
                        0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndConstNode("A", "B")))
                .Get();
            TryAssertion(epService, epl + "where P10 in ('A', 'B')", planInSingleJustConst);
        }
Пример #2
0
        public void TestQueryPlan2Stream()
        {
            var epl           = "select * from S0 as s0 unidirectional, S1.win:keepall() ";
            var fullTableScan = SupportQueryPlanBuilder.Start(2)
                                .SetIndexFullTableScan(1, "a")
                                .SetLookupPlanInner(0, new FullTableScanLookupPlan(0, 1, GetIndexKey("a"))).Get();

            // 2-stream unidirectional joins
            RunAssertion(epl, fullTableScan);

            var planEquals = SupportQueryPlanBuilder.Start(2)
                             .AddIndexHashSingleNonUnique(1, "a", "p10")
                             .SetLookupPlanInner(0, new IndexedTableLookupPlanSingle(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeKeyed("p00"))).Get();

            RunAssertion(epl + "where p00 = p10", planEquals);
            RunAssertion(epl + "where p00 = p10 and p00 in (p11, p12, p13)", planEquals);

            var planInMultiInner = SupportQueryPlanBuilder.Start(2)
                                   .AddIndexHashSingleNonUnique(1, "a", "p11")
                                   .AddIndexHashSingleNonUnique(1, "b", "p12")
                                   .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("p00"))).Get();

            RunAssertion(epl + "where p00 in (p11, p12)", planInMultiInner);
            RunAssertion(epl + "where p00 = p11 or p00 = p12", planInMultiInner);

            var planInMultiOuter = SupportQueryPlanBuilder.Start(planInMultiInner)
                                   .SetLookupPlanOuter(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("p00"))).Get();
            var eplOuterJoin = "select * from S0 as s0 unidirectional full outer join S1.win:keepall() ";

            RunAssertion(eplOuterJoin + "where p00 in (p11, p12)", planInMultiOuter);

            var planInMultiWConst = SupportQueryPlanBuilder.Start(2)
                                    .AddIndexHashSingleNonUnique(1, "a", "p11")
                                    .AddIndexHashSingleNonUnique(1, "b", "p12")
                                    .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeConstExprNode("A"))).Get();

            RunAssertion(epl + "where 'A' in (p11, p12)", planInMultiWConst);
            RunAssertion(epl + "where 'A' = p11 or 'A' = p12", planInMultiWConst);

            var planInMultiWAddConst = SupportQueryPlanBuilder.Start(2)
                                       .AddIndexHashSingleNonUnique(1, "a", "p12")
                                       .SetLookupPlanInner(0, new InKeywordTableLookupPlanMultiIdx(0, 1, GetIndexKeys("a"), SupportExprNodeFactory.MakeConstExprNode("A"))).Get();

            RunAssertion(epl + "where 'A' in ('B', p12)", planInMultiWAddConst);
            RunAssertion(epl + "where 'A' in ('B', 'C')", fullTableScan);

            var planInSingle = SupportQueryPlanBuilder.Start(2)
                               .AddIndexHashSingleNonUnique(1, "a", "p10")
                               .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeIdentExprNodes("p00", "p01"))).Get();

            RunAssertion(epl + "where p10 in (p00, p01)", planInSingle);

            var planInSingleWConst = SupportQueryPlanBuilder.Start(2)
                                     .AddIndexHashSingleNonUnique(1, "a", "p10")
                                     .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndIdentNode("A", "p01"))).Get();

            RunAssertion(epl + "where p10 in ('A', p01)", planInSingleWConst);

            var planInSingleJustConst = SupportQueryPlanBuilder.Start(2)
                                        .AddIndexHashSingleNonUnique(1, "a", "p10")
                                        .SetLookupPlanInner(0, new InKeywordTableLookupPlanSingleIdx(0, 1, GetIndexKey("a"), SupportExprNodeFactory.MakeConstAndConstNode("A", "B"))).Get();

            RunAssertion(epl + "where p10 in ('A', 'B')", planInSingleJustConst);
        }
Пример #3
0
 public void Run(RegressionEnvironment env)
 {
     var types = new EventType[2];
     var epl = "select * from SupportBean_S0 as S0 unidirectional, SupportBean_S1#keepall ";
     var fullTableScan = SupportQueryPlanBuilder.Start(2)
         .SetIndexFullTableScan(1, "a")
         .SetLookupPlanInner(0, new FullTableScanLookupPlanForge(0, 1, false, types, GetIndexKey("a")))
         .Get();
     // 2-stream unidirectional joins
     TryAssertion(env, epl, fullTableScan);
     var planEquals = SupportQueryPlanBuilder.Start(2)
         .AddIndexHashSingleNonUnique(1, "a", "P10")
         .SetLookupPlanInner(
             0,
             new IndexedTableLookupPlanHashedOnlyForge(
                 0,
                 1,
                 false,
                 types,
                 GetIndexKey("a"),
                 new[] {SupportExprNodeFactory.MakeKeyed("P00")},
                 null,
                 null,
                 null))
         .Get();
     TryAssertion(env, epl + "where P00 = P10", planEquals);
     TryAssertion(env, epl + "where P00 = P10 and P00 in (P11, P12, P13)", planEquals);
     var planInMultiInner = SupportQueryPlanBuilder.Start(2)
         .AddIndexHashSingleNonUnique(1, "a", "P11")
         .AddIndexHashSingleNonUnique(1, "b", "P12")
         .SetLookupPlanInner(
             0,
             new InKeywordTableLookupPlanMultiIdxForge(0, 1, false, types, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("P00")))
         .Get();
     TryAssertion(env, epl + "where P00 in (P11, P12)", planInMultiInner);
     TryAssertion(env, epl + "where P00 = P11 or P00 = P12", planInMultiInner);
     var planInMultiOuter = SupportQueryPlanBuilder.Start(planInMultiInner)
         .SetLookupPlanOuter(
             0,
             new InKeywordTableLookupPlanMultiIdxForge(0, 1, false, types, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeIdentExprNode("P00")))
         .Get();
     var eplOuterJoin = "select * from SupportBean_S0 as S0 unidirectional full outer join SupportBean_S1#keepall ";
     TryAssertion(env, eplOuterJoin + "where P00 in (P11, P12)", planInMultiOuter);
     var planInMultiWConst = SupportQueryPlanBuilder.Start(2)
         .AddIndexHashSingleNonUnique(1, "a", "P11")
         .AddIndexHashSingleNonUnique(1, "b", "P12")
         .SetLookupPlanInner(
             0,
             new InKeywordTableLookupPlanMultiIdxForge(0, 1, false, types, GetIndexKeys("a", "b"), SupportExprNodeFactory.MakeConstExprNode("A")))
         .Get();
     TryAssertion(env, epl + "where 'A' in (P11, P12)", planInMultiWConst);
     TryAssertion(env, epl + "where 'A' = P11 or 'A' = P12", planInMultiWConst);
     var planInMultiWAddConst = SupportQueryPlanBuilder.Start(2)
         .AddIndexHashSingleNonUnique(1, "a", "P12")
         .SetLookupPlanInner(
             0,
             new InKeywordTableLookupPlanMultiIdxForge(0, 1, false, types, GetIndexKeys("a"), SupportExprNodeFactory.MakeConstExprNode("A")))
         .Get();
     TryAssertion(env, epl + "where 'A' in ('B', P12)", planInMultiWAddConst);
     TryAssertion(env, epl + "where 'A' in ('B', 'C')", fullTableScan);
     var planInSingle = SupportQueryPlanBuilder.Start(2)
         .AddIndexHashSingleNonUnique(1, "a", "P10")
         .SetLookupPlanInner(
             0,
             new InKeywordTableLookupPlanSingleIdxForge(
                 0,
                 1,
                 false,
                 types,
                 GetIndexKey("a"),
                 SupportExprNodeFactory.MakeIdentExprNodes("P00", "P01")))
         .Get();
     TryAssertion(env, epl + "where P10 in (P00, P01)", planInSingle);
     var planInSingleWConst = SupportQueryPlanBuilder.Start(2)
         .AddIndexHashSingleNonUnique(1, "a", "P10")
         .SetLookupPlanInner(
             0,
             new InKeywordTableLookupPlanSingleIdxForge(
                 0,
                 1,
                 false,
                 types,
                 GetIndexKey("a"),
                 SupportExprNodeFactory.MakeConstAndIdentNode("A", "P01")))
         .Get();
     TryAssertion(env, epl + "where P10 in ('A', P01)", planInSingleWConst);
     var planInSingleJustConst = SupportQueryPlanBuilder.Start(2)
         .AddIndexHashSingleNonUnique(1, "a", "P10")
         .SetLookupPlanInner(
             0,
             new InKeywordTableLookupPlanSingleIdxForge(
                 0,
                 1,
                 false,
                 types,
                 GetIndexKey("a"),
                 SupportExprNodeFactory.MakeConstAndConstNode("A", "B")))
         .Get();
     TryAssertion(env, epl + "where P10 in ('A', 'B')", planInSingleJustConst);
 }