Пример #1
0
 public IndexAssertion(string hint, string whereClause, bool unique, IndexAssertionFAF fafAssertion)
 {
     Hint         = hint;
     WhereClause  = whereClause;
     IsUnique     = unique;
     FAFAssertion = fafAssertion;
 }
Пример #2
0
 public IndexAssertion(
     string hint,
     string whereClause,
     string expectedIndexName,
     string indexBackingClass,
     IndexAssertionFAF fafAssertion)
 {
     Hint              = hint;
     WhereClause       = whereClause;
     ExpectedIndexName = expectedIndexName;
     IndexBackingClass = indexBackingClass;
     FAFAssertion      = fafAssertion;
 }
Пример #3
0
        private void RunAssertionSelectIndexChoiceJoin(bool namedWindow)
        {
            var preloadedEventsOne = new object[] {
                new SupportSimpleBeanOne("E1", 10, 1, 2),
                new SupportSimpleBeanOne("E2", 11, 3, 4),
                new SupportSimpleBeanTwo("E1", 20, 1, 2),
                new SupportSimpleBeanTwo("E2", 21, 3, 4),
            };
            IndexAssertionFAF fafAssertion = (result) => {
                var fields = "w1.s1,w2.s2,w1.i1,w2.i2".Split(',');
                EPAssertionUtil.AssertPropsPerRowAnyOrder(result.Array, fields,
                                                          new object[][] { new object[] { "E1", "E1", 10, 20 }, new object[] { "E2", "E2", 11, 21 } });
            };

            var assertionsSingleProp = new IndexAssertion[] {
                new IndexAssertion(null, "s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", true, fafAssertion),
                new IndexAssertion(null, "l1 = l2 and s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "d1 = d2 and l1 = l2 and s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "d1 = d2 and l1 = l2", false, fafAssertion),
            };

            // single prop, no index, both declared unique (named window only)
            if (namedWindow)
            {
                AssertIndexChoiceJoin(namedWindow, new string[0], preloadedEventsOne, "std:unique(s1)", "std:unique(s2)", assertionsSingleProp);
            }

            // single prop, unique indexes, both declared keepall
            var uniqueIndex = new string[] { "create unique index W1I1 on W1(s1)", "create unique index W1I2 on W2(s2)" };

            AssertIndexChoiceJoin(namedWindow, uniqueIndex, preloadedEventsOne, "win:keepall()", "win:keepall()", assertionsSingleProp);

            // single prop, mixed indexes, both declared keepall
            var assertionsMultiProp = new IndexAssertion[] {
                new IndexAssertion(null, "s1 = s2", false, fafAssertion),
                new IndexAssertion(null, "s1 = s2 and l1 = l2", true, fafAssertion),
                new IndexAssertion(null, "l1 = l2 and s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "d1 = d2 and l1 = l2 and s1 = s2", true, fafAssertion),
                new IndexAssertion(null, "d1 = d2 and l1 = l2", false, fafAssertion),
            };

            if (namedWindow)
            {
                var mixedIndex = new string[] { "create index W1I1 on W1(s1, l1)", "create unique index W1I2 on W2(s2)" };
                AssertIndexChoiceJoin(namedWindow, mixedIndex, preloadedEventsOne, "std:unique(s1)", "win:keepall()", assertionsSingleProp);

                // multi prop, no index, both declared unique
                AssertIndexChoiceJoin(namedWindow, new string[0], preloadedEventsOne, "std:unique(s1, l1)", "std:unique(s2, l2)", assertionsMultiProp);
            }

            // multi prop, unique indexes, both declared keepall
            var uniqueIndexMulti = new string[] { "create unique index W1I1 on W1(s1, l1)", "create unique index W1I2 on W2(s2, l2)" };

            AssertIndexChoiceJoin(namedWindow, uniqueIndexMulti, preloadedEventsOne, "win:keepall()", "win:keepall()", assertionsMultiProp);

            // multi prop, mixed indexes, both declared keepall
            if (namedWindow)
            {
                var mixedIndexMulti = new string[] { "create index W1I1 on W1(s1)", "create unique index W1I2 on W2(s2, l2)" };
                AssertIndexChoiceJoin(namedWindow, mixedIndexMulti, preloadedEventsOne, "std:unique(s1, l1)", "win:keepall()", assertionsMultiProp);
            }
        }
Пример #4
0
        private void RunAssertionSelectIndexChoice(bool namedWindow)
        {
            var preloadedEventsOne         = new object[] { new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22) };
            IndexAssertionFAF fafAssertion = (result) => {
                var fields = "s1,i1".Split(',');
                EPAssertionUtil.AssertPropsPerRow(result.Array, fields, new object[][] { new object[] { "E2", 20 } });
            };

            // single index one field (plus declared unique)
            var noindexes = new string[0];

            AssertIndexChoice(namedWindow, noindexes, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = 'E2'", null, null, fafAssertion),
                new IndexAssertion(null, "s1 = 'E2' and l1 = 22", null, null, fafAssertion),
                new IndexAssertion("@Hint('index(One)')", "s1 = 'E2' and l1 = 22", null, null, fafAssertion),
                new IndexAssertion("@Hint('index(Two,bust)')", "s1 = 'E2' and l1 = 22"),             // should bust
            });

            // single index one field (plus declared unique)
            var indexOneField = new string[] { "create unique index One on MyInfra (s1)" };

            AssertIndexChoice(namedWindow, indexOneField, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = 'E2'", "One", BACKING_SINGLE_UNIQUE, fafAssertion),
                new IndexAssertion(null, "s1 in ('E2')", "One", BACKING_SINGLE_UNIQUE, fafAssertion),
                new IndexAssertion(null, "s1 = 'E2' and l1 = 22", "One", BACKING_SINGLE_UNIQUE, fafAssertion),
                new IndexAssertion("@Hint('index(One)')", "s1 = 'E2' and l1 = 22", "One", BACKING_SINGLE_UNIQUE, fafAssertion),
                new IndexAssertion("@Hint('index(Two,bust)')", "s1 = 'E2' and l1 = 22"),             // should bust
            });

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

            AssertIndexChoice(namedWindow, indexTwoField, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = 'E2'", null, null, fafAssertion),
                new IndexAssertion(null, "s1 = 'E2' and l1 = 22", "One", BACKING_MULTI_UNIQUE, fafAssertion),
            });

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

            AssertIndexChoice(namedWindow, indexSetTwo, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "s1 = 'E2'", "One", BACKING_SINGLE_DUPS, fafAssertion),
                new IndexAssertion(null, "s1 = 'E2' and l1 = 22", "One", BACKING_SINGLE_DUPS, fafAssertion),
                new IndexAssertion("@Hint('index(One)')", "s1 = 'E2' and l1 = 22", "One", BACKING_SINGLE_DUPS, fafAssertion),
                new IndexAssertion("@Hint('index(Two,One)')", "s1 = 'E2' and l1 = 22", "One", BACKING_SINGLE_DUPS, fafAssertion),
                new IndexAssertion("@Hint('index(Two,bust)')", "s1 = 'E2' and l1 = 22"),              // busted
                new IndexAssertion("@Hint('index(explicit,bust)')", "s1 = 'E2' and l1 = 22", "One", BACKING_SINGLE_DUPS, fafAssertion),
                new IndexAssertion(null, "s1 = 'E2' and d1 = 21 and l1 = 22", "Two", BACKING_MULTI_UNIQUE, fafAssertion),
                new IndexAssertion("@Hint('index(explicit,bust)')", "d1 = 22 and l1 = 22"),               // busted
            });

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

            AssertIndexChoice(namedWindow, indexSetThree, preloadedEventsOne, "std:unique(s1)",
                              new IndexAssertion[] {
                new IndexAssertion(null, "l1 between 22 and 23", "One", BACKING_SORTED_COERCED, fafAssertion),
                new IndexAssertion(null, "d1 between 21 and 22", "Two", BACKING_SORTED_COERCED, fafAssertion),
                new IndexAssertion("@Hint('index(One, bust)')", "d1 between 21 and 22"),             // busted
            });
        }
Пример #5
0
            public void Run(RegressionEnvironment env)
            {
                object[] preloadedEventsOne =
                    {new SupportSimpleBeanOne("E1", 10, 11, 12), new SupportSimpleBeanOne("E2", 20, 21, 22)};
                IndexAssertionFAF fafAssertion = result => {
                    var fields = new[] {"S1", "I1"};
                    EPAssertionUtil.AssertPropsPerRow(
                        result.Array,
                        fields,
                        new[] {new object[] {"E2", 20}});
                };

                // single index one field (plus declared unique)
                var noindexes = new string[0];
                AssertIndexChoice(
                    env,
                    namedWindow,
                    noindexes,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(null, "S1 = 'E2'", null, null, fafAssertion),
                        new IndexAssertion(null, "S1 = 'E2' and L1 = 22", null, null, fafAssertion),
                        new IndexAssertion("@Hint('index(One)')", "S1 = 'E2' and L1 = 22", null, null, fafAssertion),
                        new IndexAssertion("@Hint('index(Two,bust)')", "S1 = 'E2' and L1 = 22") // should bust
                    });

                // single index one field (plus declared unique)
                string[] indexOneField = {"create unique index One on MyInfra (S1)"};
                AssertIndexChoice(
                    env,
                    namedWindow,
                    indexOneField,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(null, "S1 = 'E2'", "One", BACKING_SINGLE_UNIQUE, fafAssertion),
                        new IndexAssertion(null, "S1 in ('E2')", "One", BACKING_SINGLE_UNIQUE, fafAssertion),
                        new IndexAssertion(null, "S1 = 'E2' and L1 = 22", "One", BACKING_SINGLE_UNIQUE, fafAssertion),
                        new IndexAssertion(
                            "@Hint('index(One)')",
                            "S1 = 'E2' and L1 = 22",
                            "One",
                            BACKING_SINGLE_UNIQUE,
                            fafAssertion),
                        new IndexAssertion("@Hint('index(Two,bust)')", "S1 = 'E2' and L1 = 22") // should bust
                    });

                // single index two field (plus declared unique)
                string[] indexTwoField = {"create unique index One on MyInfra (S1, L1)"};
                AssertIndexChoice(
                    env,
                    namedWindow,
                    indexTwoField,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(null, "S1 = 'E2'", null, null, fafAssertion),
                        new IndexAssertion(null, "S1 = 'E2' and L1 = 22", "One", BACKING_MULTI_UNIQUE, fafAssertion)
                    });

                // two index one unique (plus declared unique)
                string[] indexSetTwo = {
                    "create index One on MyInfra (S1)",
                    "create unique index Two on MyInfra (S1, D1)"
                };
                AssertIndexChoice(
                    env,
                    namedWindow,
                    indexSetTwo,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(null, "S1 = 'E2'", "One", BACKING_SINGLE_DUPS, fafAssertion),
                        new IndexAssertion(null, "S1 = 'E2' and L1 = 22", "One", BACKING_SINGLE_DUPS, fafAssertion),
                        new IndexAssertion(
                            "@Hint('index(One)')",
                            "S1 = 'E2' and L1 = 22",
                            "One",
                            BACKING_SINGLE_DUPS,
                            fafAssertion),
                        new IndexAssertion(
                            "@Hint('index(Two,One)')",
                            "S1 = 'E2' and L1 = 22",
                            "One",
                            BACKING_SINGLE_DUPS,
                            fafAssertion),
                        new IndexAssertion("@Hint('index(Two,bust)')", "S1 = 'E2' and L1 = 22"), // busted
                        new IndexAssertion(
                            "@Hint('index(explicit,bust)')",
                            "S1 = 'E2' and L1 = 22",
                            "One",
                            BACKING_SINGLE_DUPS,
                            fafAssertion),
                        new IndexAssertion(
                            null,
                            "S1 = 'E2' and D1 = 21 and L1 = 22",
                            "Two",
                            BACKING_MULTI_UNIQUE,
                            fafAssertion),
                        new IndexAssertion("@Hint('index(explicit,bust)')", "D1 = 22 and L1 = 22") // busted
                    });

                // range (unique)
                string[] indexSetThree = {
                    "create index One on MyInfra (L1 btree)",
                    "create index Two on MyInfra (D1 btree)"
                };
                AssertIndexChoice(
                    env,
                    namedWindow,
                    indexSetThree,
                    preloadedEventsOne,
                    "std:unique(S1)",
                    new[] {
                        new IndexAssertion(null, "L1 between 22 and 23", "One", BACKING_SORTED, fafAssertion),
                        new IndexAssertion(null, "D1 between 21 and 22", "Two", BACKING_SORTED, fafAssertion),
                        new IndexAssertion("@Hint('index(One, bust)')", "D1 between 21 and 22") // busted
                    });
            }
Пример #6
0
            public void Run(RegressionEnvironment env)
            {
                object[] preloadedEventsOne = {
                    new SupportSimpleBeanOne("E1", 10, 1, 2),
                    new SupportSimpleBeanOne("E2", 11, 3, 4),
                    new SupportSimpleBeanTwo("E1", 20, 1, 2),
                    new SupportSimpleBeanTwo("E2", 21, 3, 4)
                };
                IndexAssertionFAF fafAssertion = result => {
                    var fields = new[] {"w1.S1", "w2.S2", "w1.I1", "w2.I2"};
                    EPAssertionUtil.AssertPropsPerRowAnyOrder(
                        result.Array,
                        fields,
                        new[] {new object[] {"E1", "E1", 10, 20}, new object[] {"E2", "E2", 11, 21}});
                };

                IndexAssertion[] assertionsSingleProp = {
                    new IndexAssertion(null, "S1 = S2", true, fafAssertion),
                    new IndexAssertion(null, "S1 = S2 and L1 = L2", true, fafAssertion),
                    new IndexAssertion(null, "L1 = L2 and S1 = S2", true, fafAssertion),
                    new IndexAssertion(null, "D1 = D2 and L1 = L2 and S1 = S2", true, fafAssertion),
                    new IndexAssertion(null, "D1 = D2 and L1 = L2", false, fafAssertion)
                };

                // single prop, no index, both declared unique (named window only)
                if (namedWindow) {
                    AssertIndexChoiceJoin(
                        env,
                        namedWindow,
                        new string[0],
                        preloadedEventsOne,
                        "std:unique(S1)",
                        "std:unique(S2)",
                        assertionsSingleProp);
                }

                // single prop, unique indexes, both declared keepall
                string[] uniqueIndex = {"create unique index W1I1 on W1(S1)", "create unique index W1I2 on W2(S2)"};
                AssertIndexChoiceJoin(
                    env,
                    namedWindow,
                    uniqueIndex,
                    preloadedEventsOne,
                    "win:keepall()",
                    "win:keepall()",
                    assertionsSingleProp);

                // single prop, mixed indexes, both declared keepall
                IndexAssertion[] assertionsMultiProp = {
                    new IndexAssertion(null, "S1 = S2", false, fafAssertion),
                    new IndexAssertion(null, "S1 = S2 and L1 = L2", true, fafAssertion),
                    new IndexAssertion(null, "L1 = L2 and S1 = S2", true, fafAssertion),
                    new IndexAssertion(null, "D1 = D2 and L1 = L2 and S1 = S2", true, fafAssertion),
                    new IndexAssertion(null, "D1 = D2 and L1 = L2", false, fafAssertion)
                };
                if (namedWindow) {
                    string[] mixedIndex = {"create index W1I1 on W1(S1, L1)", "create unique index W1I2 on W2(S2)"};
                    AssertIndexChoiceJoin(
                        env,
                        namedWindow,
                        mixedIndex,
                        preloadedEventsOne,
                        "std:unique(S1)",
                        "win:keepall()",
                        assertionsSingleProp);

                    // multi prop, no index, both declared unique
                    AssertIndexChoiceJoin(
                        env,
                        namedWindow,
                        new string[0],
                        preloadedEventsOne,
                        "std:unique(S1, L1)",
                        "std:unique(S2, L2)",
                        assertionsMultiProp);
                }

                // multi prop, unique indexes, both declared keepall
                string[] uniqueIndexMulti =
                    {"create unique index W1I1 on W1(S1, L1)", "create unique index W1I2 on W2(S2, L2)"};
                AssertIndexChoiceJoin(
                    env,
                    namedWindow,
                    uniqueIndexMulti,
                    preloadedEventsOne,
                    "win:keepall()",
                    "win:keepall()",
                    assertionsMultiProp);

                // multi prop, mixed indexes, both declared keepall
                if (namedWindow) {
                    string[] mixedIndexMulti =
                        {"create index W1I1 on W1(S1)", "create unique index W1I2 on W2(S2, L2)"};
                    AssertIndexChoiceJoin(
                        env,
                        namedWindow,
                        mixedIndexMulti,
                        preloadedEventsOne,
                        "std:unique(S1, L1)",
                        "win:keepall()",
                        assertionsMultiProp);
                }
            }