Ejemplo n.º 1
0
        private static IList<FilterTestMultiStmtExecution> ComputePermutationsCase(
            Type originator,
            PermutationSpec permutationSpec,
            FilterTestMultiStmtPermutable permutableCase,
            bool withStats)
        {
            if (!permutationSpec.IsAll) {
                return Collections.SingletonList(
                    CaseOf(originator, permutationSpec.Specific, permutableCase, withStats));
            }

            // determine that filters is different
            ISet<string> filtersUnique = new HashSet<string>(Arrays.AsList(permutableCase.Filters));
            if (filtersUnique.Count == 1 && permutableCase.Filters.Length > 1) {
                Assert.Fail("Filters are all the same, specify a single permutation instead");
            }

            IList<FilterTestMultiStmtExecution> executions = new List<FilterTestMultiStmtExecution>();
            var permutationEnumerator = PermutationEnumerator.Create(permutableCase.Filters.Length);
            foreach (var permutation in permutationEnumerator) {
                executions.Add(CaseOf(originator, permutation, permutableCase, withStats));
            }

            return executions;
        }
Ejemplo n.º 2
0
        private void ComparePermutations(
            bool expected,
            ExprNode[] setOne,
            ExprNode[] setTwo)
        {
            if (setTwo.Length == 0)
            {
                CompareSingle(expected, setOne, setTwo);
                return;
            }

            var permuter = PermutationEnumerator.Create(setTwo.Length).GetEnumerator();

            for (; permuter.MoveNext();)
            {
                var permutation = permuter.Current;
                var copy        = new ExprNode[setTwo.Length];
                for (var i = 0; i < permutation.Length; i++)
                {
                    copy[i] = setTwo[permutation[i]];
                }

                CompareSingle(expected, setOne, copy);
            }
        }
Ejemplo n.º 3
0
        private static RowRegexExprNodeAlteration ExpandPermute(RowRegexExprNodePermute permute)
        {
            var e      = PermutationEnumerator.Create(permute.ChildNodes.Count);
            var parent = new RowRegexExprNodeAlteration();

            foreach (int[] indexes in e)
            {
                var concat = new RowRegexExprNodeConcatenation();
                parent.AddChildNode(concat);
                for (var i = 0; i < indexes.Length; i++)
                {
                    RowRegexExprNode toCopy = permute.ChildNodes[indexes[i]];
                    var copy = CheckedCopy(toCopy);
                    concat.AddChildNode(copy);
                }
            }
            return(parent);
        }
Ejemplo n.º 4
0
        private static RowRecogExprNodeAlteration ExpandPermute(
            RowRecogExprNodePermute permute, 
            ExpressionCopier expressionCopier)
        {
            var e = PermutationEnumerator.Create(permute.ChildNodes.Count);
            var parent = new RowRecogExprNodeAlteration();
            foreach (var indexes in e) {
                var concat = new RowRecogExprNodeConcatenation();
                parent.AddChildNode(concat);
                for (var i = 0; i < indexes.Length; i++) {
                    var toCopy = permute.ChildNodes[indexes[i]];
                    var copy = toCopy.CheckedCopy(expressionCopier);
                    concat.AddChildNode(copy);
                }
            }

            return parent;
        }
Ejemplo n.º 5
0
        private void ComparePermutations(bool expected, ExprNode[] setOne, ExprNode[] setTwo)
        {
            if (setTwo.Length == 0)
            {
                CompareSingle(expected, setOne, setTwo);
                return;
            }
            var permuter = PermutationEnumerator.Create(setTwo.Length);

            foreach (var permutation in permuter)
            {
                var copy = new ExprNode[setTwo.Length];
                for (int i = 0; i < permutation.Length; i++)
                {
                    copy[i] = setTwo[permutation[i]];
                }
                CompareSingle(expected, setOne, copy);
            }
        }
Ejemplo n.º 6
0
        public void TryPermute(bool soda, string pattern)
        {
            string epl = "select * from SupportBean " +
                         "match_recognize (" +
                         " partition by intPrimitive" +
                         " measures A as a, B as b, C as c" +
                         " pattern (" + pattern + ")" +
                         " define" +
                         " A as A.theString like \"A%\"," +
                         " B as B.theString like \"B%\"," +
                         " C as C.theString like \"C%\"" +
                         ")";
            EPStatement stmt = SupportModelHelper.CreateByCompileOrParse(_epService, soda, epl);

            stmt.AddListener(_listener);

            string[] prefixes = "A,B,C".Split(',');
            string[] fields   = "a,b,c".Split(',');

            var e     = PermutationEnumerator.Create(3);
            int count = 0;

            foreach (int[] indexes in e)
            {
                var expected = new object[3];
                for (int i = 0; i < 3; i++)
                {
                    expected[indexes[i]] = SendEvent(prefixes[indexes[i]] + count.ToString(), count);
                }
                count++;

                EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, expected);
            }

            stmt.Dispose();
        }
Ejemplo n.º 7
0
        public static void TryPermute(
            RegressionEnvironment env,
            bool soda,
            string pattern)
        {
            var epl = "@Name('s0') select * from SupportBean " +
                      "match_recognize (" +
                      " partition by IntPrimitive" +
                      " measures A as a, B as b, C as c" +
                      " pattern (" +
                      pattern +
                      ")" +
                      " define" +
                      " A as A.TheString like \"A%\"," +
                      " B as B.TheString like \"B%\"," +
                      " C as C.TheString like \"C%\"" +
                      ")";
            env.CompileDeploy(soda, epl).AddListener("s0");

            var prefixes = new [] { "A","B","C" };
            var fields = new [] { "a","b","c" };
            var count = 0;

            foreach (var indexes in PermutationEnumerator.Create(3)) {
                var expected = new object[3];
                for (var i = 0; i < 3; i++) {
                    expected[indexes[i]] = SendEvent(env, prefixes[indexes[i]] + Convert.ToString(count), count);
                }

                count++;

                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, expected);
            }

            env.UndeployAll();
        }