Esempio n. 1
0
 public IndexAssertion(string hint, string whereClause, bool unique, IndexAssertionEventSend eventSendAssertion)
 {
     Hint               = hint;
     WhereClause        = whereClause;
     IsUnique           = unique;
     EventSendAssertion = eventSendAssertion;
 }
Esempio n. 2
0
        private static void TryAssertion(
            RegressionEnvironment env,
            bool disableImplicitUniqueIdx,
            string uniqueFields,
            string whereClause,
            string backingTable,
            IndexAssertionEventSend assertion)
        {
            SupportQueryPlanIndexHook.Reset();
            var eplUnique = "@Name('s0')" +
                            INDEX_CALLBACK_HOOK +
                            "select S1 as c0, " +
                            "(select S2 from SupportSimpleBeanTwo#unique(" +
                            uniqueFields +
                            ") as ssb2 " +
                            whereClause +
                            ") as c1 " +
                            "from SupportSimpleBeanOne as ssb1";
            if (disableImplicitUniqueIdx) {
                eplUnique = "@Hint('DISABLE_UNIQUE_IMPLICIT_IDX')" + eplUnique;
            }

            env.CompileDeploy(eplUnique).AddListener("s0");

            SupportQueryPlanIndexHook.AssertSubqueryBackingAndReset(SUBQUERY_NUM_FIRST, null, backingTable);

            assertion.Invoke();

            env.UndeployAll();
        }
Esempio n. 3
0
        public void TestCoercion()
        {
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBeanRange));
            const string eplDeclare  = "create table varagg as (k0 int primary key, total sum(long))";
            const string eplPopulate = "into table varagg select sum(LongPrimitive) as total from SupportBean group by IntPrimitive";
            const string eplQuery    = "select total as value from SupportBeanRange unidirectional";

            var createIndexEmpty = new string[] {};
            var preloadedEvents  = new object[] { MakeEvent("G1", 10, 1000L), MakeEvent("G2", 20, 2000L),
                                                  MakeEvent("G3", 30, 3000L), MakeEvent("G4", 40, 4000L) };
            IndexAssertionEventSend eventSendAssertion = () =>
            {
                _epService.EPRuntime.SendEvent(new SupportBeanRange(20L));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetNewDataListFlattened(), "value".Split(','),
                                                          new object[][] { new object[] { 2000L } });
                _listener.Reset();
            };

            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexEmpty, preloadedEvents,
                              new IndexAssertion[] {
                new IndexAssertion("k0 = keyLong", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertion),
                new IndexAssertion("k0 = keyLong", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertion),
            }
                              );
        }
Esempio n. 4
0
 public IndexAssertion(
     string whereClause,
     string expectedIndexName,
     Type expectedStrategy,
     IndexAssertionEventSend eventSendAssertion)
 {
     WhereClause        = whereClause;
     ExpectedIndexName  = expectedIndexName;
     EventSendAssertion = eventSendAssertion;
     ExpectedStrategy   = expectedStrategy;
 }
Esempio n. 5
0
 public IndexAssertion(
     string hint,
     string whereClause,
     string expectedIndexName,
     string indexBackingClass,
     IndexAssertionEventSend eventSendAssertion)
 {
     Hint               = hint;
     WhereClause        = whereClause;
     ExpectedIndexName  = expectedIndexName;
     IndexBackingClass  = indexBackingClass;
     EventSendAssertion = eventSendAssertion;
 }
        private void RunAssertionIndexChoicesJoinUniqueVirtualDW(RegressionEnvironment env)
        {
            // test no where clause with unique on multiple props, exact specification of where-clause
            IndexAssertionEventSend assertSendEvents = () => {
                var fields = new [] { "vdw.TheString","vdw.IntPrimitive","ssb1.I1" };
                env.SendEventBean(new SupportSimpleBeanOne("S1", 1, 102, 103));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"S1", 101, 1});
            };

            foreach (var caseEnum in EnumHelper.GetValues<CaseEnum>()) {
                TryAssertionVirtualDW(
                    env,
                    caseEnum,
                    "TheString",
                    "where vdw.TheString = ssb1.S1",
                    true,
                    assertSendEvents);
                TryAssertionVirtualDW(
                    env,
                    caseEnum,
                    "I1",
                    "where vdw.TheString = ssb1.S1",
                    false,
                    assertSendEvents);
                TryAssertionVirtualDW(
                    env,
                    caseEnum,
                    "IntPrimitive",
                    "where vdw.TheString = ssb1.S1",
                    false,
                    assertSendEvents);
                TryAssertionVirtualDW(
                    env,
                    caseEnum,
                    "LongPrimitive",
                    "where vdw.LongPrimitive = ssb1.L1",
                    true,
                    assertSendEvents);
                TryAssertionVirtualDW(
                    env,
                    caseEnum,
                    "LongPrimitive,TheString",
                    "where vdw.TheString = ssb1.S1 and vdw.LongPrimitive = ssb1.L1",
                    true,
                    assertSendEvents);
            }
        }
Esempio n. 7
0
            public void Run(RegressionEnvironment env)
            {
                var eplDeclare = "create table varagg as (k0 int primary key, total sum(long))";
                var eplPopulate =
                    "into table varagg select sum(LongPrimitive) as total from SupportBean group by IntPrimitive";
                var eplQuery = "select total as value from SupportBeanRange unidirectional";

                string[] createIndexEmpty = { };
                object[] preloadedEvents = {
                    MakeEvent("G1", 10, 1000L), MakeEvent("G2", 20, 2000L),
                    MakeEvent("G3", 30, 3000L), MakeEvent("G4", 40, 4000L)
                };
                var milestone = new AtomicLong();

                IndexAssertionEventSend eventSendAssertion = () => {
                    env.SendEventBean(new SupportBeanRange(20L));
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        env.Listener("s0").NewDataListFlattened,
                        new[] {"value"},
                        new[] {new object[] {2000L}});
                    env.Listener("s0").Reset();
                };

                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexEmpty,
                    preloadedEvents,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k0 = KeyLong",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertion),
                        new IndexAssertion(
                            "k0 = KeyLong",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertion)
                    }
                );
            }
Esempio n. 8
0
        public void TestIndexChoicesOverdefinedWhere()
        {
            _epService.EPAdministrator.Configuration.AddEventType("SSB1", typeof(SupportSimpleBeanOne));
            _epService.EPAdministrator.Configuration.AddEventType("SSB2", typeof(SupportSimpleBeanTwo));

            // test no where clause with unique
            IndexAssertionEventSend assertNoWhere = () =>
            {
                String[] fields = "c0,c1".Split(',');
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 1, 2, 3));
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanOne("EX", 10, 11, 12));
                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "EX", "E1" });
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 1, 2, 3));
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanOne("EY", 10, 11, 12));
                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "EY", null });
            };

            RunAssertion(false, "s2,i2", "", BACKING_UNINDEXED, assertNoWhere);

            // test no where clause with unique on multiple props, exact specification of where-clause
            IndexAssertionEventSend assertSendEvents = () =>
            {
                String[] fields = "c0,c1".Split(',');
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 1, 3, 10));
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 1, 2, 0));
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E3", 1, 3, 9));
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanOne("EX", 1, 3, 9));
                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "EX", "E3" });
            };

            RunAssertion(false, "d2,i2", "where ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", BACKING_MULTI_UNIQUE, assertSendEvents);
            RunAssertion(false, "d2,i2", "where ssb2.d2 = ssb1.d1 and ssb2.i2 = ssb1.i1", BACKING_MULTI_UNIQUE, assertSendEvents);
            RunAssertion(false, "d2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.d2 = ssb1.d1 and ssb2.i2 = ssb1.i1", BACKING_MULTI_UNIQUE, assertSendEvents);
            RunAssertion(false, "d2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1", BACKING_MULTI_DUPS, assertSendEvents);
            RunAssertion(false, "d2,i2", "where ssb2.d2 = ssb1.d1", BACKING_SINGLE_DUPS, assertSendEvents);
            RunAssertion(false, "d2,i2", "where ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1 and ssb2.l2 between 1 and 1000", BACKING_MULTI_UNIQUE, assertSendEvents);
            RunAssertion(false, "d2,i2", "where ssb2.d2 = ssb1.d1 and ssb2.l2 between 1 and 1000", BACKING_COMPOSITE, assertSendEvents);
            RunAssertion(false, "i2,d2,l2", "where ssb2.l2 = ssb1.l1 and ssb2.d2 = ssb1.d1", BACKING_MULTI_DUPS, assertSendEvents);
            RunAssertion(false, "i2,d2,l2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", BACKING_MULTI_UNIQUE, assertSendEvents);
            RunAssertion(false, "d2,l2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", BACKING_MULTI_UNIQUE, assertSendEvents);
            RunAssertion(false, "d2,l2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1 and ssb2.s2 between 'E3' and 'E4'", BACKING_MULTI_UNIQUE, assertSendEvents);
            RunAssertion(false, "l2", "where ssb2.l2 = ssb1.l1", BACKING_SINGLE_UNIQUE, assertSendEvents);
            RunAssertion(true, "l2", "where ssb2.l2 = ssb1.l1", BACKING_SINGLE_DUPS, assertSendEvents);
            RunAssertion(false, "l2", "where ssb2.l2 = ssb1.l1 and ssb1.i1 between 1 and 20", BACKING_SINGLE_UNIQUE, assertSendEvents);
        }
        private void TryAssertionVirtualDW(
            RegressionEnvironment env,
            CaseEnum caseEnum,
            string uniqueFields,
            string whereClause,
            bool unique,
            IndexAssertionEventSend assertion)
        {
            SupportQueryPlanIndexHook.Reset();
            SupportVirtualDWForge.UniqueKeys = new HashSet<string>(Arrays.AsList(uniqueFields.SplitCsv()));

            var path = new RegressionPath();
            env.CompileDeploy("create window MyVDW.test:vdw() as SupportBean", path);
            var window = (SupportVirtualDW) GetFromContext(env, "/virtualdw/MyVDW");
            var supportBean = new SupportBean("S1", 101);
            supportBean.DoublePrimitive = 102;
            supportBean.LongPrimitive = 103;
            window.Data = Collections.SingletonSet<object>(supportBean);

            var eplUnique = IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                            "@Name('s0') select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL) {
                eplUnique += "SupportSimpleBeanOne as ssb1 unidirectional ";
            }
            else {
                eplUnique += "SupportSimpleBeanOne#lastevent as ssb1 ";
            }

            eplUnique += ", MyVDW as vdw ";
            eplUnique += whereClause;

            env.CompileDeploy(eplUnique, path).AddListener("s0");

            // assert query plan
            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            // run assertion
            assertion.Invoke();

            env.UndeployAll();
            SupportVirtualDWForge.UniqueKeys = null;
        }
Esempio n. 10
0
        private void RunAssertionNoIndexShareIndexChoice(EPServiceProvider epService, bool namedWindow)
        {
            string backingUniqueS1 = "unique hash={s1(string)} btree={} advanced={}";

            var preloadedEventsOne = new object[] { new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22) };
            var listenerStmtOne    = new SupportUpdateListener();
            var eventSendAssertion = new IndexAssertionEventSend(() => {
                string[] fields = "s2,ssb1[0].s1,ssb1[0].i1".Split(',');
                epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 50, 21, 22));
                EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E2", "E2", 20 });
                epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 60, 11, 12));
                EPAssertionUtil.AssertProps(listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E1", "E1", 10 });
            });
            var noAssertion = new IndexAssertionEventSend(() => { });

            // unique-s1
            AssertIndexChoice(epService, listenerStmtOne, namedWindow, false, new string[0], preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = ssb2.s2", namedWindow ? null : "MyInfra", namedWindow ? BACKING_SINGLE_UNIQUE : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2 and l1 = ssb2.l2", namedWindow ? null : "MyInfra", namedWindow ? BACKING_SINGLE_UNIQUE : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "i1 between 1 and 10", null, namedWindow ? BACKING_SORTED : null, noAssertion),
                new IndexAssertion(null, "l1 = ssb2.l2", null, namedWindow ? BACKING_SINGLE_DUPS : null, eventSendAssertion),
            });

            // unique-s1+i1
            if (namedWindow)
            {
                AssertIndexChoice(epService, listenerStmtOne, namedWindow, false, new string[0], preloadedEventsOne, "std:unique(s1, d1)",
                                  new IndexAssertion[] {
                    new IndexAssertion(null, "s1 = ssb2.s2", null, BACKING_SINGLE_DUPS, eventSendAssertion),
                    new IndexAssertion(null, "s1 = ssb2.s2 and l1 = ssb2.l2", null, BACKING_MULTI_DUPS, eventSendAssertion),
                    new IndexAssertion(null, "s1 = ssb2.s2 and d1 = ssb2.d2", null, BACKING_MULTI_UNIQUE, eventSendAssertion),
                    new IndexAssertion(null, "s1 = ssb2.s2 and l1 = ssb2.l2 and d1 = ssb2.d2", null, BACKING_MULTI_UNIQUE, eventSendAssertion),
                    new IndexAssertion(null, "d1 = ssb2.d2 and s1 = ssb2.s2 and l1 = ssb2.l2", null, BACKING_MULTI_UNIQUE, eventSendAssertion),
                    new IndexAssertion(null, "l1 = ssb2.l2 and s1 = ssb2.s2 and d1 = ssb2.d2", null, BACKING_MULTI_UNIQUE, eventSendAssertion),
                });
            }
        }
Esempio n. 11
0
        public void TestIndexChoicesJoinUniqueVirtualDW()
        {
            _epService.EPAdministrator.Configuration.AddEventType <SupportSimpleBeanOne>("SSB1");

            // test no where clause with unique on multiple props, exact specification of where-clause
            IndexAssertionEventSend assertSendEvents = () =>
            {
                var fields = "vdw.TheString,vdw.IntPrimitive,ssb1.i1".Split(',');
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanOne("S1", 1, 102, 103));
                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "S1", 101, 1 });
            };

            var testCases = EnumHelper.GetValues <CaseEnum>();

            foreach (var caseEnum in testCases)
            {
                RunAssertionVirtualDw(caseEnum, "TheString", "where vdw.TheString = ssb1.s1", true, assertSendEvents);
                RunAssertionVirtualDw(caseEnum, "i1", "where vdw.TheString = ssb1.s1", false, assertSendEvents);
                RunAssertionVirtualDw(caseEnum, "IntPrimitive", "where vdw.TheString = ssb1.s1", false, assertSendEvents);
                RunAssertionVirtualDw(caseEnum, "LongPrimitive", "where vdw.LongPrimitive = ssb1.l1", true, assertSendEvents);
                RunAssertionVirtualDw(caseEnum, "LongPrimitive,TheString", "where vdw.TheString = ssb1.s1 and vdw.LongPrimitive = ssb1.l1", true, assertSendEvents);
            }
        }
Esempio n. 12
0
        private void RunAssertionIndexChoicesJoinUniqueVirtualDW(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType("SSB1", typeof(SupportSimpleBeanOne));
            var listener = new SupportUpdateListener();

            // test no where clause with unique on multiple props, exact specification of where-clause
            var assertSendEvents = new IndexAssertionEventSend(() => {
                string[] fields = "vdw.TheString,vdw.IntPrimitive,ssb1.i1".Split(',');
                epService.EPRuntime.SendEvent(new SupportSimpleBeanOne("S1", 1, 102, 103));
                EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "S1", 101, 1 });
            });

            var testCases = EnumHelper.GetValues <CaseEnum>();

            foreach (CaseEnum caseEnum in testCases)
            {
                TryAssertionVirtualDW(epService, listener, caseEnum, "TheString", "where vdw.TheString = ssb1.s1", true, assertSendEvents);
                TryAssertionVirtualDW(epService, listener, caseEnum, "i1", "where vdw.TheString = ssb1.s1", false, assertSendEvents);
                TryAssertionVirtualDW(epService, listener, caseEnum, "IntPrimitive", "where vdw.TheString = ssb1.s1", false, assertSendEvents);
                TryAssertionVirtualDW(epService, listener, caseEnum, "LongPrimitive", "where vdw.LongPrimitive = ssb1.l1", true, assertSendEvents);
                TryAssertionVirtualDW(epService, listener, caseEnum, "LongPrimitive,TheString", "where vdw.TheString = ssb1.s1 and vdw.LongPrimitive = ssb1.l1", true, assertSendEvents);
            }
        }
Esempio n. 13
0
        public void TestIndexChoicesJoinUnique()
        {
            _epService.EPAdministrator.Configuration.AddEventType("SSB1", typeof(SupportSimpleBeanOne));
            _epService.EPAdministrator.Configuration.AddEventType("SSB2", typeof(SupportSimpleBeanTwo));
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            // test no where clause with unique on multiple props, exact specification of where-clause
            IndexAssertionEventSend assertSendEvents =
                () =>
            {
                String[] fields = "ssb1.s1,ssb2.s2".Split(',');
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 1, 3, 10));
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 1, 2, 0));
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E3", 1, 3, 9));
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanOne("EX", 1, 3, 9));
                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "EX", "E3" });
            };

            IEnumerable <CaseEnum> testCases = EnumHelper.GetValues <CaseEnum>();

            foreach (CaseEnum caseEnum in testCases)
            {
                RunAssertion(caseEnum, "d2,i2", "where ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", true, assertSendEvents);
                RunAssertion(caseEnum, "d2,i2", "where ssb2.d2 = ssb1.d1 and ssb2.i2 = ssb1.i1", true, assertSendEvents);
                RunAssertion(caseEnum, "d2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.d2 = ssb1.d1 and ssb2.i2 = ssb1.i1", true, assertSendEvents);
                RunAssertion(caseEnum, "d2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1", false, assertSendEvents);
                RunAssertion(caseEnum, "d2,i2", "where ssb2.d2 = ssb1.d1", false, assertSendEvents);
                RunAssertion(caseEnum, "d2,i2", "where ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1 and ssb2.l2 between 1 and 1000", true, assertSendEvents);
                RunAssertion(caseEnum, "d2,i2", "where ssb2.d2 = ssb1.d1 and ssb2.l2 between 1 and 1000", false, assertSendEvents);
                RunAssertion(caseEnum, "i2,d2,l2", "where ssb2.l2 = ssb1.l1 and ssb2.d2 = ssb1.d1", false, assertSendEvents);
                RunAssertion(caseEnum, "i2,d2,l2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", true, assertSendEvents);
                RunAssertion(caseEnum, "d2,l2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", true, assertSendEvents);
                RunAssertion(caseEnum, "d2,l2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1 and ssb2.s2 between 'E3' and 'E4'", true, assertSendEvents);
                RunAssertion(caseEnum, "l2", "where ssb2.l2 = ssb1.l1", true, assertSendEvents);
                RunAssertion(caseEnum, "l2", "where ssb2.l2 = ssb1.l1 and ssb1.i1 between 1 and 20", true, assertSendEvents);
            }
        }
Esempio n. 14
0
        public void RunAssertionNoIndexShareIndexChoice(bool namedWindow)
        {
            var backingUniqueS1 = "unique hash={S1(string)} btree={}";

            var preloadedEventsOne = new object[] { new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22) };
            IndexAssertionEventSend eventSendAssertion = () => {
                var fields = "S2,ssb1[0].S1,ssb1[0].I1".Split(',');
                _epRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 50, 21, 22));
                EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E2", "E2", 20 });
                _epRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 60, 11, 12));
                EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E1", "E1", 10 });
            };
            IndexAssertionEventSend noAssertion = () => {};

            // unique-s1
            AssertIndexChoice(namedWindow, false, new string[0], preloadedEventsOne, "std:unique(S1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "S1 = ssb2.S2", namedWindow ? null : "MyInfra", namedWindow ? BACKING_SINGLE_UNIQUE : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2 and L1 = ssb2.L2", namedWindow ? null : "MyInfra", namedWindow ? BACKING_SINGLE_UNIQUE : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "I1 between 1 and 10", null, namedWindow ? BACKING_SORTED : null, noAssertion),
                new IndexAssertion(null, "L1 = ssb2.L2", null, namedWindow ? BACKING_SINGLE_DUPS : null, eventSendAssertion),
            });

            // unique-s1+I1
            if (namedWindow)
            {
                AssertIndexChoice(namedWindow, false, new string[0], preloadedEventsOne, "std:unique(S1, D1)",
                                  new IndexAssertion[] {
                    new IndexAssertion(null, "S1 = ssb2.S2", null, BACKING_SINGLE_DUPS, eventSendAssertion),
                    new IndexAssertion(null, "S1 = ssb2.S2 and L1 = ssb2.L2", null, BACKING_MULTI_DUPS, eventSendAssertion),
                    new IndexAssertion(null, "S1 = ssb2.S2 and D1 = ssb2.D2", null, BACKING_MULTI_UNIQUE, eventSendAssertion),
                    new IndexAssertion(null, "S1 = ssb2.S2 and L1 = ssb2.L2 and D1 = ssb2.D2", null, BACKING_MULTI_UNIQUE, eventSendAssertion),
                    new IndexAssertion(null, "D1 = ssb2.D2 and S1 = ssb2.S2 and L1 = ssb2.L2", null, BACKING_MULTI_UNIQUE, eventSendAssertion),
                    new IndexAssertion(null, "L1 = ssb2.L2 and S1 = ssb2.S2 and D1 = ssb2.D2", null, BACKING_MULTI_UNIQUE, eventSendAssertion),
                });
            }
        }
Esempio n. 15
0
        private void RunAssertion(
            RegressionEnvironment env,
            AtomicLong milestone,
            CaseEnum caseEnum,
            string uniqueFields,
            string whereClause,
            bool unique,
            IndexAssertionEventSend assertion)
        {
            SupportQueryPlanIndexHook.Reset();
            var eplUnique = IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                            "@Name('s0') select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL || caseEnum == CaseEnum.UNIDIRECTIONAL_3STREAM) {
                eplUnique += "SupportSimpleBeanOne as ssb1 unidirectional ";
            }
            else {
                eplUnique += "SupportSimpleBeanOne#lastevent as ssb1 ";
            }

            eplUnique += ", SupportSimpleBeanTwo#unique(" + uniqueFields + ") as ssb2 ";
            if (caseEnum == CaseEnum.UNIDIRECTIONAL_3STREAM || caseEnum == CaseEnum.MULTIDIRECTIONAL_3STREAM) {
                eplUnique += ", SupportBean#lastevent ";
            }

            eplUnique += whereClause;

            env.CompileDeployAddListenerMile(eplUnique, "s0", milestone.GetAndIncrement());

            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            env.SendEventBean(new SupportBean("JOINEVENT", 1));
            assertion.Invoke();

            env.UndeployAll();
        }
Esempio n. 16
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType("SSB1", typeof(SupportSimpleBeanOne));
            epService.EPAdministrator.Configuration.AddEventType("SSB2", typeof(SupportSimpleBeanTwo));
            epService.EPAdministrator.Configuration.AddEventType <SupportBean>();
            var listener = new SupportUpdateListener();

            // test no where clause with unique on multiple props, exact specification of where-clause
            var assertSendEvents = new IndexAssertionEventSend(() => {
                string[] fields = "ssb1.s1,ssb2.s2".Split(',');
                epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 1, 3, 10));
                epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 1, 2, 0));
                epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E3", 1, 3, 9));
                epService.EPRuntime.SendEvent(new SupportSimpleBeanOne("EX", 1, 3, 9));
                EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "EX", "E3" });
            });

            var testCases = EnumHelper.GetValues <CaseEnum>();

            foreach (CaseEnum caseEnum in testCases)
            {
                RunAssertion(epService, listener, caseEnum, "d2,i2", "where ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", true, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "d2,i2", "where ssb2.d2 = ssb1.d1 and ssb2.i2 = ssb1.i1", true, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "d2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.d2 = ssb1.d1 and ssb2.i2 = ssb1.i1", true, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "d2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1", false, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "d2,i2", "where ssb2.d2 = ssb1.d1", false, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "d2,i2", "where ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1 and ssb2.l2 between 1 and 1000", true, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "d2,i2", "where ssb2.d2 = ssb1.d1 and ssb2.l2 between 1 and 1000", false, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "i2,d2,l2", "where ssb2.l2 = ssb1.l1 and ssb2.d2 = ssb1.d1", false, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "i2,d2,l2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", true, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "d2,l2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1", true, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "d2,l2,i2", "where ssb2.l2 = ssb1.l1 and ssb2.i2 = ssb1.i1 and ssb2.d2 = ssb1.d1 and ssb2.s2 between 'E3' and 'E4'", true, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "l2", "where ssb2.l2 = ssb1.l1", true, assertSendEvents);
                RunAssertion(epService, listener, caseEnum, "l2", "where ssb2.l2 = ssb1.l1 and ssb1.i1 between 1 and 20", true, assertSendEvents);
            }
        }
Esempio n. 17
0
        private void RunAssertion(bool disableImplicitUniqueIdx, String uniqueFields, String whereClause, String backingTable, IndexAssertionEventSend assertion)
        {
            String eplUnique = INDEX_CALLBACK_HOOK + "select s1 as c0, " +
                               "(select s2 from SSB2.std:unique(" + uniqueFields + ") as ssb2 " + whereClause + ") as c1 " +
                               "from SSB1 as ssb1";

            if (disableImplicitUniqueIdx)
            {
                eplUnique = "@Hint('DISABLE_UNIQUE_IMPLICIT_IDX')" + eplUnique;
            }
            EPStatement stmtUnique = _epService.EPAdministrator.CreateEPL(eplUnique);

            stmtUnique.Events += _listener.Update;

            SupportQueryPlanIndexHook.AssertSubqueryBackingAndReset(0, null, backingTable);

            assertion.Invoke();

            stmtUnique.Dispose();
        }
Esempio n. 18
0
            public void Run(RegressionEnvironment env)
            {
                var eplDeclare =
                    "create table varagg as (k0 string primary key, k1 int primary key, v1 string, total sum(long))";
                var eplPopulate =
                    "into table varagg select sum(LongPrimitive) as total from SupportBean group by TheString, IntPrimitive";
                var eplQuery = "select total as value from SupportBean_S0 as S0 unidirectional";

                string[] createIndexEmpty = { };
                object[] preloadedEventsTwo = {
                    MakeEvent("G1", 10, 1000L), MakeEvent("G2", 20, 2000L),
                    MakeEvent("G3", 30, 3000L), MakeEvent("G4", 40, 4000L)
                };
                var milestone = new AtomicLong();

                IndexAssertionEventSend eventSendAssertionRangeTwoExpected = () => {
                    env.SendEventBean(new SupportBean_S0(-1, null));
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        env.Listener("s0").NewDataListFlattened,
                        new[] {"value"},
                        new[] {new object[] {2000L}, new object[] {3000L}});
                    env.Listener("s0").Reset();
                };

                object[] preloadedEventsHash = {MakeEvent("G1", 10, 1000L)};
                IndexAssertionEventSend eventSendAssertionHash = () => {
                    env.SendEventBean(new SupportBean_S0(10, "G1"));
                    EPAssertionUtil.AssertPropsPerRow(
                        env.Listener("s0").NewDataListFlattened,
                        new[] {"value"},
                        new[] {new object[] {1000L}});
                    env.Listener("s0").Reset();
                };

                // no secondary indexes
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexEmpty,
                    preloadedEventsHash,
                    milestone,
                    new[] {
                        // primary index found
                        new IndexAssertion(
                            "k1 = Id and k0 = P00",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "k0 = P00 and k1 = Id",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "k0 = P00 and k1 = Id and v1 is null",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // no index found
                        new IndexAssertion(
                            "k1 = Id",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionHash)
                    }
                );

                // one secondary hash index on single field
                string[] createIndexHashSingleK1 = {"create index idx_k1 on varagg (k1)"};
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexHashSingleK1,
                    preloadedEventsHash,
                    milestone,
                    new[] {
                        // primary index found
                        new IndexAssertion(
                            "k1 = Id and k0 = P00",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // secondary index found
                        new IndexAssertion(
                            "k1 = Id",
                            "idx_k1",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "Id = k1",
                            "idx_k1",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // no index found
                        new IndexAssertion(
                            "k0 = P00",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionHash)
                    }
                );

                // two secondary hash indexes on one field each
                string[] createIndexHashTwoDiscrete =
                    {"create index idx_k1 on varagg (k1)", "create index idx_k0 on varagg (k0)"};
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexHashTwoDiscrete,
                    preloadedEventsHash,
                    milestone,
                    new[] {
                        // primary index found
                        new IndexAssertion(
                            "k1 = Id and k0 = P00",
                            "varagg",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // secondary index found
                        new IndexAssertion(
                            "k0 = P00",
                            "idx_k0",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "k1 = Id",
                            "idx_k1",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        new IndexAssertion(
                            "v1 is null and k1 = Id",
                            "idx_k1",
                            typeof(IndexedTableLookupPlanHashedOnlyForge),
                            eventSendAssertionHash),
                        // no index found
                        new IndexAssertion(
                            "1=1",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionHash)
                    }
                );

                // one range secondary index
                // no secondary indexes
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexEmpty,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        // no index found
                        new IndexAssertion(
                            "k1 between 20 and 30",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionRangeTwoExpected)
                    }
                );

                // single range secondary index, expecting two events
                string[] createIndexRangeOne = {"create index b_k1 on varagg (k1 btree)"};
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexRangeOne,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k1 between 20 and 30",
                            "b_k1",
                            typeof(SortedTableLookupPlanForge),
                            eventSendAssertionRangeTwoExpected),
                        new IndexAssertion(
                            "(k0 = 'G3' or k0 = 'G2') and k1 between 20 and 30",
                            "b_k1",
                            typeof(SortedTableLookupPlanForge),
                            eventSendAssertionRangeTwoExpected)
                    }
                );

                // single range secondary index, expecting single event
                IndexAssertionEventSend eventSendAssertionRangeOneExpected = () => {
                    env.SendEventBean(new SupportBean_S0(-1, null));
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        env.Listener("s0").NewDataListFlattened,
                        new[] {"value"},
                        new[] {new object[] {2000L}});
                    env.Listener("s0").Reset();
                };
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexRangeOne,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k0 = 'G2' and k1 between 20 and 30",
                            "b_k1",
                            typeof(SortedTableLookupPlanForge),
                            eventSendAssertionRangeOneExpected),
                        new IndexAssertion(
                            "k1 between 20 and 30 and k0 = 'G2'",
                            "b_k1",
                            typeof(SortedTableLookupPlanForge),
                            eventSendAssertionRangeOneExpected)
                    }
                );

                // combined hash+range index
                string[] createIndexRangeCombined = {"create index h_k0_b_k1 on varagg (k0 hash, k1 btree)"};
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexRangeCombined,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k0 = 'G2' and k1 between 20 and 30",
                            "h_k0_b_k1",
                            typeof(CompositeTableLookupPlanForge),
                            eventSendAssertionRangeOneExpected),
                        new IndexAssertion(
                            "k1 between 20 and 30 and k0 = 'G2'",
                            "h_k0_b_k1",
                            typeof(CompositeTableLookupPlanForge),
                            eventSendAssertionRangeOneExpected)
                    }
                );

                string[] createIndexHashSingleK0 = {"create index idx_k0 on varagg (k0)"};
                // in-keyword single-directional use
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexHashSingleK0,
                    preloadedEventsTwo,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "k0 in ('G2', 'G3')",
                            "idx_k0",
                            typeof(InKeywordTableLookupPlanSingleIdxForge),
                            eventSendAssertionRangeTwoExpected)
                    }
                );
                // in-keyword multi-directional use
                AssertIndexChoice(
                    env,
                    eplDeclare,
                    eplPopulate,
                    eplQuery,
                    createIndexHashSingleK0,
                    preloadedEventsHash,
                    milestone,
                    new[] {
                        new IndexAssertion(
                            "'G1' in (k0)",
                            "varagg",
                            typeof(FullTableScanUniquePerKeyLookupPlanForge),
                            eventSendAssertionHash)
                    }
                );
            }
Esempio n. 19
0
            public void Run(RegressionEnvironment env)
            {
                var milestone = new AtomicLong();

                // test no where clause with unique
                IndexAssertionEventSend assertNoWhere = () => {
                    var fields = new[] {"c0", "c1"};
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 1, 2, 3));

                    env.MilestoneInc(milestone);

                    env.SendEventBean(new SupportSimpleBeanOne("EX", 10, 11, 12));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"EX", "E1"});
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 1, 2, 3));

                    env.MilestoneInc(milestone);

                    env.SendEventBean(new SupportSimpleBeanOne("EY", 10, 11, 12));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"EY", null});
                };

                TryAssertion(env, false, "S2,I2", "", BACKING_UNINDEXED, assertNoWhere);

                // test no where clause with unique on multiple props, exact specification of where-clause
                IndexAssertionEventSend assertSendEvents = () => {
                    var fields = new[] {"c0", "c1"};
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 1, 3, 10));
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 1, 2, 0));
                    env.SendEventBean(new SupportSimpleBeanTwo("E3", 1, 3, 9));

                    env.MilestoneInc(milestone);

                    env.SendEventBean(new SupportSimpleBeanOne("EX", 1, 3, 9));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"EX", "E3"});
                };

                TryAssertion(
                    env,
                    false,
                    "D2,I2",
                    "where ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1",
                    BACKING_MULTI_UNIQUE,
                    assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "D2,I2",
                    "where ssb2.D2 = ssb1.D1 and ssb2.I2 = ssb1.I1",
                    BACKING_MULTI_UNIQUE,
                    assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "D2,I2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.D2 = ssb1.D1 and ssb2.I2 = ssb1.I1",
                    BACKING_MULTI_UNIQUE,
                    assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "D2,I2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.I2 = ssb1.I1",
                    BACKING_MULTI_DUPS,
                    assertSendEvents);
                TryAssertion(env, false, "D2,I2", "where ssb2.D2 = ssb1.D1", BACKING_SINGLE_DUPS, assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "D2,I2",
                    "where ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1 and ssb2.L2 between 1 and 1000",
                    BACKING_MULTI_UNIQUE,
                    assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "D2,I2",
                    "where ssb2.D2 = ssb1.D1 and ssb2.L2 between 1 and 1000",
                    BACKING_COMPOSITE,
                    assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "I2,D2,L2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.D2 = ssb1.D1",
                    BACKING_MULTI_DUPS,
                    assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "I2,D2,L2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1",
                    BACKING_MULTI_UNIQUE,
                    assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "D2,L2,I2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1",
                    BACKING_MULTI_UNIQUE,
                    assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "D2,L2,I2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1 and ssb2.S2 between 'E3' and 'E4'",
                    BACKING_MULTI_UNIQUE,
                    assertSendEvents);
                TryAssertion(env, false, "L2", "where ssb2.L2 = ssb1.L1", BACKING_SINGLE_UNIQUE, assertSendEvents);
                TryAssertion(env, true, "L2", "where ssb2.L2 = ssb1.L1", BACKING_SINGLE_DUPS, assertSendEvents);
                TryAssertion(
                    env,
                    false,
                    "L2",
                    "where ssb2.L2 = ssb1.L1 and ssb1.I1 between 1 and 20",
                    BACKING_SINGLE_UNIQUE,
                    assertSendEvents);

                // greater
                IndexAssertionEventSend assertGreater = () => {
                    var fields = new[] {"c0", "c1"};
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 1));
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 2));

                    env.MilestoneInc(milestone);

                    SendAssert(
                        env,
                        "A",
                        1,
                        fields,
                        new object[] {"A", null});
                    SendAssert(
                        env,
                        "B",
                        2,
                        fields,
                        new object[] {"B", "E1"});
                    SendAssert(
                        env,
                        "C",
                        3,
                        fields,
                        new object[] {"C", null});
                    SendAssert(
                        env,
                        "D",
                        4,
                        fields,
                        new object[] {"D", null});
                    SendAssert(
                        env,
                        "E",
                        5,
                        fields,
                        new object[] {"E", null});
                };
                TryAssertion(env, false, "S2", "where ssb1.I1 > ssb2.I2", BACKING_SORTED, assertGreater);

                // greater-equals
                IndexAssertionEventSend assertGreaterEquals = () => {
                    var fields = new[] {"c0", "c1"};
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 2));
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 4));

                    env.MilestoneInc(milestone);

                    SendAssert(
                        env,
                        "A",
                        1,
                        fields,
                        new object[] {"A", null});
                    SendAssert(
                        env,
                        "B",
                        2,
                        fields,
                        new object[] {"B", "E1"});
                    SendAssert(
                        env,
                        "C",
                        3,
                        fields,
                        new object[] {"C", "E1"});
                    SendAssert(
                        env,
                        "D",
                        4,
                        fields,
                        new object[] {"D", null});
                    SendAssert(
                        env,
                        "E",
                        5,
                        fields,
                        new object[] {"E", null});
                };
                TryAssertion(env, false, "S2", "where ssb1.I1 >= ssb2.I2", BACKING_SORTED, assertGreaterEquals);

                // less
                IndexAssertionEventSend assertLess = () => {
                    var fields = new[] {"c0", "c1"};
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 2));
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 3));

                    env.MilestoneInc(milestone);

                    SendAssert(
                        env,
                        "A",
                        1,
                        fields,
                        new object[] {"A", null});
                    SendAssert(
                        env,
                        "B",
                        2,
                        fields,
                        new object[] {"B", "E2"});
                    SendAssert(
                        env,
                        "C",
                        3,
                        fields,
                        new object[] {"C", null});
                    SendAssert(
                        env,
                        "D",
                        4,
                        fields,
                        new object[] {"D", null});
                    SendAssert(
                        env,
                        "E",
                        5,
                        fields,
                        new object[] {"E", null});
                };
                TryAssertion(env, false, "S2", "where ssb1.I1 < ssb2.I2", BACKING_SORTED, assertLess);

                // less-equals
                IndexAssertionEventSend assertLessEquals = () => {
                    var fields = new[] {"c0", "c1"};
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 1));
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 3));

                    env.MilestoneInc(milestone);

                    SendAssert(
                        env,
                        "A",
                        1,
                        fields,
                        new object[] {"A", null});
                    SendAssert(
                        env,
                        "B",
                        2,
                        fields,
                        new object[] {"B", "E2"});
                    SendAssert(
                        env,
                        "C",
                        3,
                        fields,
                        new object[] {"C", "E2"});
                    SendAssert(
                        env,
                        "D",
                        4,
                        fields,
                        new object[] {"D", null});
                    SendAssert(
                        env,
                        "E",
                        5,
                        fields,
                        new object[] {"E", null});
                };
                TryAssertion(env, false, "S2", "where ssb1.I1 <= ssb2.I2", BACKING_SORTED, assertLessEquals);
            }
Esempio n. 20
0
        private void RunAssertionIndexShareIndexChoice(EPServiceProvider epService, bool namedWindow)
        {
            string backingUniqueS1    = "unique hash={s1(string)} btree={} advanced={}";
            string backingUniqueS1L1  = "unique hash={s1(string),l1(long)} btree={} advanced={}";
            string backingUniqueS1D1  = "unique hash={s1(string),d1(double)} btree={} advanced={}";
            string backingNonUniqueS1 = "non-unique hash={s1(string)} btree={} advanced={}";
            string backingNonUniqueD1 = "non-unique hash={d1(double)} btree={} advanced={}";
            string backingBtreeI1     = "non-unique hash={} btree={i1(int)} advanced={}";
            string backingBtreeD1     = "non-unique hash={} btree={d1(double)} advanced={}";
            string primaryIndexTable  = namedWindow ? null : "MyInfra";

            var preloadedEventsOne = new object[] { new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22) };
            var listener           = new SupportUpdateListener();
            var eventSendAssertion = new IndexAssertionEventSend(() => {
                string[] fields = "s2,ssb1[0].s1,ssb1[0].i1".Split(',');
                epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 50, 21, 22));
                EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2", "E2", 20 });
                epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 60, 11, 12));
                EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", "E1", 10 });
            });

            // no index one field (essentially duplicated since declared std:unique)
            var noindexes = new string[] {};

            AssertIndexChoice(epService, listener, namedWindow, true, noindexes, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = ssb2.s2", primaryIndexTable, backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2 and l1 = ssb2.l2", primaryIndexTable, backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(One)')", "s1 = ssb2.s2 and l1 = ssb2.l2", primaryIndexTable, backingUniqueS1, eventSendAssertion),
            });

            // single index one field (essentially duplicated since declared std:unique)
            if (namedWindow)
            {
                var indexOneField = new string[] { "create unique index One on MyInfra (s1)" };
                AssertIndexChoice(epService, listener, namedWindow, true, indexOneField, preloadedEventsOne, "std:unique(s1)",
                                  new IndexAssertion[] {
                    new IndexAssertion(null, "s1 = ssb2.s2", "One", backingUniqueS1, eventSendAssertion),
                    new IndexAssertion(null, "s1 = ssb2.s2 and l1 = ssb2.l2", "One", backingUniqueS1, eventSendAssertion),
                    new IndexAssertion("@Hint('index(One)')", "s1 = ssb2.s2 and l1 = ssb2.l2", "One", backingUniqueS1, eventSendAssertion),
                });
            }

            // single index two field
            var indexTwoField = new string[] { "create unique index One on MyInfra (s1, l1)" };

            AssertIndexChoice(epService, listener, namedWindow, true, indexTwoField, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = ssb2.s2", primaryIndexTable, backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2 and l1 = ssb2.l2", "One", backingUniqueS1L1, eventSendAssertion),
            });

            // two index one unique with std:unique(s1)
            var indexSetTwo = new string[] {
                "create index One on MyInfra (s1)",
                "create unique index Two on MyInfra (s1, d1)"
            };

            AssertIndexChoice(epService, listener, namedWindow, true, indexSetTwo, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "d1 = ssb2.d2", null, namedWindow ? backingNonUniqueD1 : null, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2 and l1 = ssb2.l2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(One)')", "s1 = ssb2.s2 and l1 = ssb2.l2", "One", backingNonUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(Two,One)')", "s1 = ssb2.s2 and l1 = ssb2.l2", "One", backingNonUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(Two,bust)')", "s1 = ssb2.s2 and l1 = ssb2.l2"),             // busted
                new IndexAssertion("@Hint('index(explicit,bust)')", "s1 = ssb2.s2 and l1 = ssb2.l2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2 and d1 = ssb2.d2 and l1 = ssb2.l2", namedWindow ? "Two" : "MyInfra", namedWindow ? backingUniqueS1D1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(explicit,bust)')", "d1 = ssb2.d2 and l1 = ssb2.l2")             // busted
            });

            // two index one unique with keep-all
            AssertIndexChoice(epService, listener, namedWindow, true, indexSetTwo, preloadedEventsOne, "win:keepall()",
                              new IndexAssertion[] {
                new IndexAssertion(null, "d1 = ssb2.d2", null, namedWindow ? backingNonUniqueD1 : null, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2 and l1 = ssb2.l2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(One)')", "s1 = ssb2.s2 and l1 = ssb2.l2", "One", backingNonUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(Two,One)')", "s1 = ssb2.s2 and l1 = ssb2.l2", "One", backingNonUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(Two,bust)')", "s1 = ssb2.s2 and l1 = ssb2.l2"),             // busted
                new IndexAssertion("@Hint('index(explicit,bust)')", "s1 = ssb2.s2 and l1 = ssb2.l2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "s1 = ssb2.s2 and d1 = ssb2.d2 and l1 = ssb2.l2", namedWindow ? "Two" : "MyInfra", namedWindow ? backingUniqueS1D1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(explicit,bust)')", "d1 = ssb2.d2 and l1 = ssb2.l2")             // busted
            });

            // range
            var noAssertion = new IndexAssertionEventSend(() => {
            });

            var indexSetThree = new string[] {
                "create index One on MyInfra (i1 btree)",
                "create index Two on MyInfra (d1 btree)"
            };

            AssertIndexChoice(epService, listener, namedWindow, true, indexSetThree, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "i1 between 1 and 10", "One", backingBtreeI1, noAssertion),
                new IndexAssertion(null, "d1 between 1 and 10", "Two", backingBtreeD1, noAssertion),
                new IndexAssertion("@Hint('index(One, bust)')", "d1 between 1 and 10"),             // busted
            });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false);
        }
Esempio n. 21
0
            public void Run(RegressionEnvironment env)
            {
                object[] preloadedEventsOne =
                    {new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22)};
                IndexAssertionEventSend eventSendAssertion = () => {
                    var fields = new [] { "ssb2.S2","ssb1.S1","ssb1.I1" };
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 50, 21, 22));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E2", "E2", 20});
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 60, 11, 12));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E1", "E1", 10});
                };

                // no index, since this is "unique(S1)" we don't need one
                string[] noindexes = { };
                AssertIndexChoice(
                    env,
                    noindexes,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new IndexAssertion(null, "S1 = S2", true, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2 and L1 = L2", true, eventSendAssertion));

                // single index one field (duplicate in essence, since "unique(S1)"
                string[] indexOneField = {"create unique index One on MyWindow (S1)"};
                AssertIndexChoice(
                    env,
                    indexOneField,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new IndexAssertion(null, "S1 = S2", true, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2 and L1 = L2", true, eventSendAssertion));

                // single index two field (includes "unique(S1)")
                string[] indexTwoField = {"create unique index One on MyWindow (S1, L1)"};
                AssertIndexChoice(
                    env,
                    indexTwoField,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new IndexAssertion(null, "S1 = S2", true, eventSendAssertion),
                    new IndexAssertion(null, "D1 = D2", false, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2 and L1 = L2", true, eventSendAssertion));

                // two index one unique ("unique(S1)")
                string[] indexSetTwo = {
                    "create index One on MyWindow (S1)",
                    "create unique index Two on MyWindow (S1, D1)"
                };
                AssertIndexChoice(
                    env,
                    indexSetTwo,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new IndexAssertion(null, "D1 = D2", false, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2", true, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2 and L1 = L2", true, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2 and D1 = D2 and L1 = L2", true, eventSendAssertion));

                // two index one unique ("win:keepall()")
                AssertIndexChoice(
                    env,
                    indexSetTwo,
                    preloadedEventsOne,
                    "win:keepall()",
                    new IndexAssertion(null, "D1 = D2", false, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2", false, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2 and L1 = L2", false, eventSendAssertion),
                    new IndexAssertion(null, "S1 = S2 and D1 = D2 and L1 = L2", true, eventSendAssertion),
                    new IndexAssertion(null, "D1 = D2 and S1 = S2", true, eventSendAssertion));
            }
Esempio n. 22
0
            public void Run(RegressionEnvironment env)
            {
                var backingUniqueS1 = "unique hash={S1(string)} btree={} advanced={}";

                object[] preloadedEventsOne =
                    {new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22)};
                IndexAssertionEventSend eventSendAssertion = () => {
                    var fields = new[] {"S2", "ssb1[0].S1", "ssb1[0].I1"};
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 50, 21, 22));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E2", "E2", 20});
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 60, 11, 12));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E1", "E1", 10});
                };
                IndexAssertionEventSend noAssertion = () => { };

                // unique-S1
                AssertIndexChoice(
                    env,
                    namedWindow,
                    false,
                    new string[0],
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2",
                            namedWindow ? null : "MyInfra",
                            namedWindow ? BACKING_SINGLE_UNIQUE : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            namedWindow ? null : "MyInfra",
                            namedWindow ? BACKING_SINGLE_UNIQUE : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "I1 between 1 and 10",
                            null,
                            namedWindow ? BACKING_SORTED : null,
                            noAssertion),
                        new IndexAssertion(
                            null,
                            "L1 = ssb2.L2",
                            null,
                            namedWindow ? BACKING_SINGLE_DUPS : null,
                            eventSendAssertion)
                    });

                // unique-S1+I1
                if (namedWindow) {
                    AssertIndexChoice(
                        env,
                        namedWindow,
                        false,
                        new string[0],
                        preloadedEventsOne,
                        "std:unique(S1, D1)",
                        new[] {
                            new IndexAssertion(null, "S1 = ssb2.S2", null, BACKING_SINGLE_DUPS, eventSendAssertion),
                            new IndexAssertion(
                                null,
                                "S1 = ssb2.S2 and L1 = ssb2.L2",
                                null,
                                BACKING_MULTI_DUPS,
                                eventSendAssertion),
                            new IndexAssertion(
                                null,
                                "S1 = ssb2.S2 and D1 = ssb2.D2",
                                null,
                                BACKING_MULTI_UNIQUE,
                                eventSendAssertion),
                            new IndexAssertion(
                                null,
                                "S1 = ssb2.S2 and L1 = ssb2.L2 and D1 = ssb2.D2",
                                null,
                                BACKING_MULTI_UNIQUE,
                                eventSendAssertion),
                            new IndexAssertion(
                                null,
                                "D1 = ssb2.D2 and S1 = ssb2.S2 and L1 = ssb2.L2",
                                null,
                                BACKING_MULTI_UNIQUE,
                                eventSendAssertion),
                            new IndexAssertion(
                                null,
                                "L1 = ssb2.L2 and S1 = ssb2.S2 and D1 = ssb2.D2",
                                null,
                                BACKING_MULTI_UNIQUE,
                                eventSendAssertion)
                        });
                }
            }
Esempio n. 23
0
        private void RunAssertionIndexShareIndexChoice(bool namedWindow)
        {
            var backingUniqueS1    = "unique hash={S1(string)} btree={}";
            var backingUniqueS1L1  = "unique hash={S1(string),L1(long)} btree={}";
            var backingUniqueS1D1  = "unique hash={S1(string),D1(double)} btree={}";
            var backingNonUniqueS1 = "non-unique hash={S1(string)} btree={}";
            var backingNonUniqueD1 = "non-unique hash={D1(double)} btree={}";
            var backingBtreeI1     = "non-unique hash={} btree={I1(int)}";
            var backingBtreeD1     = "non-unique hash={} btree={D1(double)}";
            var primaryIndexTable  = namedWindow ? null : "MyInfra";

            var preloadedEventsOne = new object[] { new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22) };
            IndexAssertionEventSend eventSendAssertion = () => {
                var fields = "S2,ssb1[0].S1,ssb1[0].I1".Split(',');
                _epRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 50, 21, 22));
                EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E2", "E2", 20 });
                _epRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 60, 11, 12));
                EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E1", "E1", 10 });
            };

            // no index one field (essentially duplicated since declared std:unique)
            var noindexes = new string[] {};

            AssertIndexChoice(namedWindow, true, noindexes, preloadedEventsOne, "std:unique(S1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "S1 = ssb2.S2", primaryIndexTable, backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2 and L1 = ssb2.L2", primaryIndexTable, backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(One)')", "S1 = ssb2.S2 and L1 = ssb2.L2", primaryIndexTable, backingUniqueS1, eventSendAssertion),
            });

            // single index one field (essentially duplicated since declared std:unique)
            if (namedWindow)
            {
                var indexOneField = new string[] { "create unique index One on MyInfra (S1)" };
                AssertIndexChoice(namedWindow, true, indexOneField, preloadedEventsOne, "std:unique(S1)",
                                  new IndexAssertion[] {
                    new IndexAssertion(null, "S1 = ssb2.S2", "One", backingUniqueS1, eventSendAssertion),
                    new IndexAssertion(null, "S1 = ssb2.S2 and L1 = ssb2.L2", "One", backingUniqueS1, eventSendAssertion),
                    new IndexAssertion("@Hint('index(One)')", "S1 = ssb2.S2 and L1 = ssb2.L2", "One", backingUniqueS1, eventSendAssertion),
                });
            }

            // single index two field
            var indexTwoField = new string[] { "create unique index One on MyInfra (S1, L1)" };

            AssertIndexChoice(namedWindow, true, indexTwoField, preloadedEventsOne, "std:unique(S1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "S1 = ssb2.S2", primaryIndexTable, backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2 and L1 = ssb2.L2", "One", backingUniqueS1L1, eventSendAssertion),
            });

            // two index one unique with std:unique(S1)
            var indexSetTwo = new string[] {
                "create index One on MyInfra (S1)",
                "create unique index Two on MyInfra (S1, D1)"
            };

            AssertIndexChoice(namedWindow, true, indexSetTwo, preloadedEventsOne, "std:unique(S1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "D1 = ssb2.D2", null, namedWindow ? backingNonUniqueD1 : null, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2 and L1 = ssb2.L2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(One)')", "S1 = ssb2.S2 and L1 = ssb2.L2", "One", backingNonUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(Two,One)')", "S1 = ssb2.S2 and L1 = ssb2.L2", "One", backingNonUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(Two,bust)')", "S1 = ssb2.S2 and L1 = ssb2.L2"),             // busted
                new IndexAssertion("@Hint('index(explicit,bust)')", "S1 = ssb2.S2 and L1 = ssb2.L2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2 and D1 = ssb2.D2 and L1 = ssb2.L2", namedWindow ? "Two" : "MyInfra", namedWindow ? backingUniqueS1D1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(explicit,bust)')", "D1 = ssb2.D2 and L1 = ssb2.L2")             // busted
            });

            // two index one unique with keep-all
            AssertIndexChoice(namedWindow, true, indexSetTwo, preloadedEventsOne, "win:keepall()",
                              new IndexAssertion[] {
                new IndexAssertion(null, "D1 = ssb2.D2", null, namedWindow ? backingNonUniqueD1 : null, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2 and L1 = ssb2.L2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(One)')", "S1 = ssb2.S2 and L1 = ssb2.L2", "One", backingNonUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(Two,One)')", "S1 = ssb2.S2 and L1 = ssb2.L2", "One", backingNonUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(Two,bust)')", "S1 = ssb2.S2 and L1 = ssb2.L2"),             // busted
                new IndexAssertion("@Hint('index(explicit,bust)')", "S1 = ssb2.S2 and L1 = ssb2.L2", namedWindow ? "One" : "MyInfra", namedWindow ? backingNonUniqueS1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion(null, "S1 = ssb2.S2 and D1 = ssb2.D2 and L1 = ssb2.L2", namedWindow ? "Two" : "MyInfra", namedWindow ? backingUniqueS1D1 : backingUniqueS1, eventSendAssertion),
                new IndexAssertion("@Hint('index(explicit,bust)')", "D1 = ssb2.D2 and L1 = ssb2.L2")             // busted
            });

            // range
            IndexAssertionEventSend noAssertion = () => {};
            var indexSetThree = new string[] {
                "create index One on MyInfra (I1 btree)",
                "create index Two on MyInfra (D1 btree)"
            };

            AssertIndexChoice(namedWindow, true, indexSetThree, preloadedEventsOne, "std:unique(S1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "I1 between 1 and 10", "One", backingBtreeI1, noAssertion),
                new IndexAssertion(null, "D1 between 1 and 10", "Two", backingBtreeD1, noAssertion),
                new IndexAssertion("@Hint('index(One, bust)')", "D1 between 1 and 10"),             // busted
            });

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false);
        }
Esempio n. 24
0
        private void RunAssertion(CaseEnum caseEnum, String uniqueFields, String whereClause, bool unique, IndexAssertionEventSend assertion)
        {
            String eplUnique = INDEX_CALLBACK_HOOK +
                               "select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL || caseEnum == CaseEnum.UNIDIRECTIONAL_3STREAM)
            {
                eplUnique += "SSB1 as ssb1 unidirectional ";
            }
            else
            {
                eplUnique += "SSB1#lastevent as ssb1 ";
            }
            eplUnique += ", SSB2#unique(" + uniqueFields + ") as ssb2 ";
            if (caseEnum == CaseEnum.UNIDIRECTIONAL_3STREAM || caseEnum == CaseEnum.MULTIDIRECTIONAL_3STREAM)
            {
                eplUnique += ", SupportBean#lastevent ";
            }
            eplUnique += whereClause;

            EPStatement stmtUnique = _epService.EPAdministrator.CreateEPL(eplUnique);

            stmtUnique.Events += _listener.Update;

            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            _epService.EPRuntime.SendEvent(new SupportBean("JOINEVENT", 1));
            assertion.Invoke();

            stmtUnique.Dispose();
        }
Esempio n. 25
0
            public void Run(RegressionEnvironment env)
            {
                string[] noindexes = { };
                var backingUniqueS1 = "unique hash={S1(string)} btree={} advanced={}";
                var backingUniqueS1L1 = "unique hash={S1(string),L1(long)} btree={} advanced={}";
                var backingUniqueS1D1 = "unique hash={S1(string),D1(double)} btree={} advanced={}";
                var backingNonUniqueS1 = "non-unique hash={S1(string)} btree={} advanced={}";
                var backingNonUniqueD1 = "non-unique hash={D1(double)} btree={} advanced={}";
                var backingBtreeI1 = "non-unique hash={} btree={I1(int)} advanced={}";
                var backingBtreeD1 = "non-unique hash={} btree={D1(double)} advanced={}";
                var primaryIndexTable = namedWindow ? "MyNWIndex" : "MyInfra";
                var primaryIndexEPL = "create unique index MyNWIndex on MyInfra(S1)";

                object[] preloadedEventsOne =
                    {new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22)};
                IndexAssertionEventSend eventSendAssertion = () => {
                    var fields = new[] {"S2", "ssb1[0].S1", "ssb1[0].I1"};
                    env.SendEventBean(new SupportSimpleBeanTwo("E2", 50, 21, 22));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E2", "E2", 20});
                    env.SendEventBean(new SupportSimpleBeanTwo("E1", 60, 11, 12));
                    EPAssertionUtil.AssertProps(
                        env.Listener("s0").AssertOneGetNewAndReset(),
                        fields,
                        new object[] {"E1", "E1", 10});
                };

                // no index one field (essentially duplicated since declared std:unique)
                var primaryIndex = AppendArrayConditional(noindexes, namedWindow, primaryIndexEPL);
                AssertIndexChoice(
                    env,
                    namedWindow,
                    true,
                    primaryIndex,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2",
                            primaryIndexTable,
                            backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            primaryIndexTable,
                            backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            "@Hint('index(One)')",
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            primaryIndexTable,
                            backingUniqueS1,
                            eventSendAssertion)
                    });

                // single index one field (essentially duplicated since declared std:unique)
                if (namedWindow) {
                    string[] indexOneField = {"create unique index One on MyInfra (S1)"};
                    AssertIndexChoice(
                        env,
                        namedWindow,
                        true,
                        indexOneField,
                        preloadedEventsOne,
                        "std:unique(S1)",
                        new[] {
                            new IndexAssertion(null, "S1 = ssb2.S2", "One", backingUniqueS1, eventSendAssertion),
                            new IndexAssertion(
                                null,
                                "S1 = ssb2.S2 and L1 = ssb2.L2",
                                "One",
                                backingUniqueS1,
                                eventSendAssertion),
                            new IndexAssertion(
                                "@Hint('index(One)')",
                                "S1 = ssb2.S2 and L1 = ssb2.L2",
                                "One",
                                backingUniqueS1,
                                eventSendAssertion)
                        });
                }

                // single index two field
                var secondaryEPL = "create unique index One on MyInfra (S1, L1)";
                var indexTwoField = AppendArrayConditional(secondaryEPL, namedWindow, primaryIndexEPL);
                AssertIndexChoice(
                    env,
                    namedWindow,
                    true,
                    indexTwoField,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2",
                            primaryIndexTable,
                            backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            "One",
                            backingUniqueS1L1,
                            eventSendAssertion)
                    });

                // two index one unique with std:unique(S1)
                string[] indexSetTwo = {
                    "create index One on MyInfra (S1)",
                    "create unique index Two on MyInfra (S1, D1)"
                };
                AssertIndexChoice(
                    env,
                    namedWindow,
                    true,
                    indexSetTwo,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(null, "D1 = ssb2.D2", null, null, eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2",
                            namedWindow ? "One" : "MyInfra",
                            namedWindow ? backingNonUniqueS1 : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            namedWindow ? "One" : "MyInfra",
                            namedWindow ? backingNonUniqueS1 : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            "@Hint('index(One)')",
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            "One",
                            backingNonUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            "@Hint('index(Two,One)')",
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            "One",
                            backingNonUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion("@Hint('index(Two,bust)')", "S1 = ssb2.S2 and L1 = ssb2.L2"), // busted
                        new IndexAssertion(
                            "@Hint('index(explicit,bust)')",
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            namedWindow ? "One" : "MyInfra",
                            namedWindow ? backingNonUniqueS1 : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2 and D1 = ssb2.D2 and L1 = ssb2.L2",
                            namedWindow ? "Two" : "MyInfra",
                            namedWindow ? backingUniqueS1D1 : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion("@Hint('index(explicit,bust)')", "D1 = ssb2.D2 and L1 = ssb2.L2") // busted
                    });

                // two index one unique with keep-all
                AssertIndexChoice(
                    env,
                    namedWindow,
                    true,
                    indexSetTwo,
                    preloadedEventsOne,
                    "win:keepall()",
                    new[] {
                        new IndexAssertion(null, "D1 = ssb2.D2", null, null, eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2",
                            namedWindow ? "One" : "MyInfra",
                            namedWindow ? backingNonUniqueS1 : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            namedWindow ? "One" : "MyInfra",
                            namedWindow ? backingNonUniqueS1 : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            "@Hint('index(One)')",
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            "One",
                            backingNonUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            "@Hint('index(Two,One)')",
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            "One",
                            backingNonUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion("@Hint('index(Two,bust)')", "S1 = ssb2.S2 and L1 = ssb2.L2"), // busted
                        new IndexAssertion(
                            "@Hint('index(explicit,bust)')",
                            "S1 = ssb2.S2 and L1 = ssb2.L2",
                            namedWindow ? "One" : "MyInfra",
                            namedWindow ? backingNonUniqueS1 : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = ssb2.S2 and D1 = ssb2.D2 and L1 = ssb2.L2",
                            namedWindow ? "Two" : "MyInfra",
                            namedWindow ? backingUniqueS1D1 : backingUniqueS1,
                            eventSendAssertion),
                        new IndexAssertion("@Hint('index(explicit,bust)')", "D1 = ssb2.D2 and L1 = ssb2.L2") // busted
                    });

                // range
                IndexAssertionEventSend noAssertion = () => { };
                string[] indexSetThree = {
                    "create index One on MyInfra (I1 btree)",
                    "create index Two on MyInfra (D1 btree)"
                };
                AssertIndexChoice(
                    env,
                    namedWindow,
                    true,
                    indexSetThree,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(null, "I1 between 1 and 10", "One", backingBtreeI1, noAssertion),
                        new IndexAssertion(null, "D1 between 1 and 10", "Two", backingBtreeD1, noAssertion),
                        new IndexAssertion("@Hint('index(One, bust)')", "D1 between 1 and 10") // busted
                    });

                env.UndeployAll();
            }
Esempio n. 26
0
        public void TestJoinIndexChoice()
        {
            _epService.EPAdministrator.Configuration.AddEventType("SSB1", typeof(SupportSimpleBeanOne));
            _epService.EPAdministrator.Configuration.AddEventType("SSB2", typeof(SupportSimpleBeanTwo));

            var preloadedEventsOne = new object[] { new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22) };
            IndexAssertionEventSend eventSendAssertion = () =>
            {
                var fields = "ssb2.s2,ssb1.s1,ssb1.i1".Split(',');
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E2", 50, 21, 22));
                EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E2", "E2", 20 });
                _epService.EPRuntime.SendEvent(new SupportSimpleBeanTwo("E1", 60, 11, 12));
                EPAssertionUtil.AssertProps(_listenerStmtOne.AssertOneGetNewAndReset(), fields, new object[] { "E1", "E1", 10 });
            };

            // no index, since this is "unique(s1)" we don't need one
            var noindexes = new string[] {};

            AssertIndexChoice(noindexes, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = s2", true, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", true, eventSendAssertion),
            });

            // single index one field (duplicate in essence, since "unique(s1)"
            var indexOneField = new string[] { "create unique index One on MyWindow (s1)" };

            AssertIndexChoice(indexOneField, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = s2", true, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", true, eventSendAssertion),
            });

            // single index two field (includes "unique(s1)")
            var indexTwoField = new string[] { "create unique index One on MyWindow (s1, l1)" };

            AssertIndexChoice(indexTwoField, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = s2", true, eventSendAssertion),
                new IndexAssertion(null, "d1 = d2", false, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", true, eventSendAssertion),
            });

            // two index one unique ("unique(s1)")
            var indexSetTwo = new string[] {
                "create index One on MyWindow (s1)",
                "create unique index Two on MyWindow (s1, d1)"
            };

            AssertIndexChoice(indexSetTwo, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "d1 = d2", false, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2", true, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", true, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2 and d1 = d2 and l1 = l2", true, eventSendAssertion),
            });

            // two index one unique ("win:keepall()")
            AssertIndexChoice(indexSetTwo, preloadedEventsOne, "win:keepall()",
                              new IndexAssertion[] {
                new IndexAssertion(null, "d1 = d2", false, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2", false, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", false, eventSendAssertion),
                new IndexAssertion(null, "s1 = s2 and d1 = d2 and l1 = l2", true, eventSendAssertion),
                new IndexAssertion(null, "d1 = d2 and s1 = s2", true, eventSendAssertion),
            });
        }
Esempio n. 27
0
        private void TryAssertionVirtualDW(EPServiceProvider epService, SupportUpdateListener listener, CaseEnum caseEnum, string uniqueFields, string whereClause, bool unique, IndexAssertionEventSend assertion)
        {
            SupportQueryPlanIndexHook.Reset();
            SupportVirtualDWFactory.UniqueKeys = new HashSet <string>(uniqueFields.Split(','));
            epService.EPAdministrator.CreateEPL("create window MyVDW.test:vdw() as SupportBean");
            SupportVirtualDW window = (SupportVirtualDW)GetFromContext(epService, "/virtualdw/MyVDW");
            var supportBean         = new SupportBean("S1", 101);

            supportBean.DoublePrimitive = 102;
            supportBean.LongPrimitive   = 103;
            window.Data = Collections.SingletonList <object>(supportBean);

            string eplUnique = INDEX_CALLBACK_HOOK +
                               "select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL)
            {
                eplUnique += "SSB1 as ssb1 unidirectional ";
            }
            else
            {
                eplUnique += "SSB1#lastevent as ssb1 ";
            }
            eplUnique += ", MyVDW as vdw ";
            eplUnique += whereClause;

            EPStatement stmtUnique = epService.EPAdministrator.CreateEPL(eplUnique);

            stmtUnique.Events += listener.Update;

            // assert query plan
            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            // run assertion
            assertion.Invoke();

            epService.EPAdministrator.DestroyAllStatements();
            DestroyStmtsRemoveTypes(epService);
        }
Esempio n. 28
0
        public void Run(RegressionEnvironment env)
        {
            var milestone = new AtomicLong();

            // test no where clause with unique on multiple props, exact specification of where-clause
            IndexAssertionEventSend assertSendEvents = () => {
                var fields = new[] {"ssb1.S1", "ssb2.S2"};
                env.SendEventBean(new SupportSimpleBeanTwo("E1", 1, 3, 10));
                env.SendEventBean(new SupportSimpleBeanTwo("E2", 1, 2, 0));
                env.SendEventBean(new SupportSimpleBeanTwo("E3", 1, 3, 9));
                env.SendEventBean(new SupportSimpleBeanOne("EX", 1, 3, 9));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"EX", "E3"});
            };

            var testCases = EnumHelper.GetValues<CaseEnum>();
            foreach (var caseEnum in testCases) {
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "D2,I2",
                    "where ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1",
                    true,
                    assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "D2,I2",
                    "where ssb2.D2 = ssb1.D1 and ssb2.I2 = ssb1.I1",
                    true,
                    assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "D2,I2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.D2 = ssb1.D1 and ssb2.I2 = ssb1.I1",
                    true,
                    assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "D2,I2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.I2 = ssb1.I1",
                    false,
                    assertSendEvents);
                RunAssertion(env, milestone, caseEnum, "D2,I2", "where ssb2.D2 = ssb1.D1", false, assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "D2,I2",
                    "where ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1 and ssb2.L2 between 1 and 1000",
                    true,
                    assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "D2,I2",
                    "where ssb2.D2 = ssb1.D1 and ssb2.L2 between 1 and 1000",
                    false,
                    assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "I2,D2,L2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.D2 = ssb1.D1",
                    false,
                    assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "I2,D2,L2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1",
                    true,
                    assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "D2,L2,I2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1",
                    true,
                    assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "D2,L2,I2",
                    "where ssb2.L2 = ssb1.L1 and ssb2.I2 = ssb1.I1 and ssb2.D2 = ssb1.D1 and ssb2.S2 between 'E3' and 'E4'",
                    true,
                    assertSendEvents);
                RunAssertion(env, milestone, caseEnum, "L2", "where ssb2.L2 = ssb1.L1", true, assertSendEvents);
                RunAssertion(
                    env,
                    milestone,
                    caseEnum,
                    "L2",
                    "where ssb2.L2 = ssb1.L1 and ssb1.I1 between 1 and 20",
                    true,
                    assertSendEvents);
            }
        }
Esempio n. 29
0
        private void RunAssertionVirtualDw(CaseEnum caseEnum, String uniqueFields, String whereClause, bool unique, IndexAssertionEventSend assertion)
        {
            SupportVirtualDWFactory.UniqueKeys = new HashSet <String>(uniqueFields.SplitCsv());
            _epService.EPAdministrator.CreateEPL("create window MyVDW.test:vdw() as SupportBean");
            var window      = (SupportVirtualDW)GetFromContext("/virtualdw/MyVDW");
            var supportBean = new SupportBean("S1", 101);

            supportBean.DoublePrimitive = 102;
            supportBean.LongPrimitive   = 103;
            window.Data = supportBean.AsSingleton();

            var eplUnique = IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL)
            {
                eplUnique += "SSB1 as ssb1 unidirectional ";
            }
            else
            {
                eplUnique += "SSB1.std:lastevent() as ssb1 ";
            }
            eplUnique += ", MyVDW as vdw ";
            eplUnique += whereClause;

            var stmtUnique = _epService.EPAdministrator.CreateEPL(eplUnique);

            stmtUnique.Events += _listener.Update;

            // assert query plan
            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            // run assertion
            assertion.Invoke();

            _epService.EPAdministrator.DestroyAllStatements();
        }
Esempio n. 30
0
        public void TestJoinIndexChoice()
        {
            const string eplDeclare  = "create table varagg as (k0 string primary key, k1 int primary key, v1 string, total sum(long))";
            const string eplPopulate = "into table varagg select sum(LongPrimitive) as total from SupportBean group by TheString, IntPrimitive";
            const string eplQuery    = "select total as value from SupportBean_S0 as s0 unidirectional";

            var createIndexEmpty   = new string[] {};
            var preloadedEventsTwo = new object[] { MakeEvent("G1", 10, 1000L), MakeEvent("G2", 20, 2000L),
                                                    MakeEvent("G3", 30, 3000L), MakeEvent("G4", 40, 4000L) };

            IndexAssertionEventSend eventSendAssertionRangeTwoExpected = () =>
            {
                _epService.EPRuntime.SendEvent(new SupportBean_S0(-1, null));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetNewDataListFlattened(), "value".Split(','),
                                                          new object[][] { new object[] { 2000L }, new object[] { 3000L } });
                _listener.Reset();
            };

            var preloadedEventsHash = new object[] { MakeEvent("G1", 10, 1000L) };
            IndexAssertionEventSend eventSendAssertionHash = () =>
            {
                _epService.EPRuntime.SendEvent(new SupportBean_S0(10, "G1"));
                EPAssertionUtil.AssertPropsPerRow(_listener.GetNewDataListFlattened(), "value".Split(','),
                                                  new object[][] { new object[] { 1000L } });
                _listener.Reset();
            };

            // no secondary indexes
            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexEmpty, preloadedEventsHash,
                              new IndexAssertion[] {
                // primary index found
                new IndexAssertion("k1 = id and k0 = p00", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                new IndexAssertion("k0 = p00 and k1 = id", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                new IndexAssertion("k0 = p00 and k1 = id and v1 is null", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                // no index found
                new IndexAssertion("k1 = id", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionHash)
            }
                              );

            // one secondary hash index on single field
            var createIndexHashSingleK1 = new string[] { "create index idx_k1 on varagg (k1)" };

            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexHashSingleK1, preloadedEventsHash,
                              new IndexAssertion[] {
                // primary index found
                new IndexAssertion("k1 = id and k0 = p00", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                // secondary index found
                new IndexAssertion("k1 = id", "idx_k1", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                new IndexAssertion("id = k1", "idx_k1", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                // no index found
                new IndexAssertion("k0 = p00", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionHash)
            }
                              );

            // two secondary hash indexes on one field each
            var createIndexHashTwoDiscrete = new string[] { "create index idx_k1 on varagg (k1)", "create index idx_k0 on varagg (k0)" };

            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexHashTwoDiscrete, preloadedEventsHash,
                              new IndexAssertion[] {
                // primary index found
                new IndexAssertion("k1 = id and k0 = p00", "varagg", typeof(IndexedTableLookupPlanMulti), eventSendAssertionHash),
                // secondary index found
                new IndexAssertion("k0 = p00", "idx_k0", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                new IndexAssertion("k1 = id", "idx_k1", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                new IndexAssertion("v1 is null and k1 = id", "idx_k1", typeof(IndexedTableLookupPlanSingle), eventSendAssertionHash),
                // no index found
                new IndexAssertion("1=1", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionHash)
            }
                              );

            // one range secondary index
            // no secondary indexes
            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexEmpty, preloadedEventsTwo,
                              new IndexAssertion[] {
                // no index found
                new IndexAssertion("k1 between 20 and 30", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionRangeTwoExpected)
            }
                              );

            // single range secondary index, expecting two events
            var createIndexRangeOne = new string[] { "create index b_k1 on varagg (k1 btree)" };

            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexRangeOne, preloadedEventsTwo,
                              new IndexAssertion[] {
                new IndexAssertion("k1 between 20 and 30", "b_k1", typeof(SortedTableLookupPlan), eventSendAssertionRangeTwoExpected),
                new IndexAssertion("(k0 = 'G3' or k0 = 'G2') and k1 between 20 and 30", "b_k1", typeof(SortedTableLookupPlan), eventSendAssertionRangeTwoExpected),
            }
                              );

            // single range secondary index, expecting single event
            IndexAssertionEventSend eventSendAssertionRangeOneExpected = () =>
            {
                _epService.EPRuntime.SendEvent(new SupportBean_S0(-1, null));
                EPAssertionUtil.AssertPropsPerRowAnyOrder(_listener.GetNewDataListFlattened(), "value".Split(','),
                                                          new object[][] { new object[] { 2000L } });
                _listener.Reset();
            };

            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexRangeOne, preloadedEventsTwo,
                              new IndexAssertion[] {
                new IndexAssertion("k0 = 'G2' and k1 between 20 and 30", "b_k1", typeof(SortedTableLookupPlan), eventSendAssertionRangeOneExpected),
                new IndexAssertion("k1 between 20 and 30 and k0 = 'G2'", "b_k1", typeof(SortedTableLookupPlan), eventSendAssertionRangeOneExpected),
            }
                              );

            // combined hash+range index
            var createIndexRangeCombined = new string[] { "create index h_k0_b_k1 on varagg (k0 hash, k1 btree)" };

            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexRangeCombined, preloadedEventsTwo,
                              new IndexAssertion[] {
                new IndexAssertion("k0 = 'G2' and k1 between 20 and 30", "h_k0_b_k1", typeof(CompositeTableLookupPlan), eventSendAssertionRangeOneExpected),
                new IndexAssertion("k1 between 20 and 30 and k0 = 'G2'", "h_k0_b_k1", typeof(CompositeTableLookupPlan), eventSendAssertionRangeOneExpected),
            }
                              );

            var createIndexHashSingleK0 = new string[] { "create index idx_k0 on varagg (k0)" };

            // in-keyword single-directional use
            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexHashSingleK0, preloadedEventsTwo,
                              new IndexAssertion[] {
                new IndexAssertion("k0 in ('G2', 'G3')", "idx_k0", typeof(InKeywordTableLookupPlanSingleIdx), eventSendAssertionRangeTwoExpected),
            }
                              );
            // in-keyword multi-directional use
            AssertIndexChoice(eplDeclare, eplPopulate, eplQuery, createIndexHashSingleK0, preloadedEventsHash,
                              new IndexAssertion[] {
                new IndexAssertion("'G1' in (k0)", "varagg", typeof(FullTableScanUniquePerKeyLookupPlan), eventSendAssertionHash),
            }
                              );
        }