Esempio n. 1
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "create table MyTableFAFU as (pKey0 string primary key, col0 int, col1 int, thecnt count(*))",
                    path);
                env.CompileDeploy("create index MyIndex on MyTableFAFU(col0)", path);

                env.CompileDeploy(
                    "into table MyTableFAFU select count(*) as thecnt from SupportBean group by TheString",
                    path);
                env.SendEventBean(new SupportBean("E1", 0));
                env.SendEventBean(new SupportBean("E2", 0));

                env.CompileExecuteFAF("update MyTableFAFU set col0 = 1 where pKey0='E1'", path);
                env.CompileExecuteFAF("update MyTableFAFU set col0 = 2 where pKey0='E2'", path);
                AssertFAFOneRowResult(
                    env,
                    path,
                    "select pKey0 from MyTableFAFU where col0=1",
                    "pKey0",
                    new object[] {"E1"});

                env.CompileExecuteFAF("update MyTableFAFU set col1 = 100 where pKey0='E1'", path);
                AssertFAFOneRowResult(
                    env,
                    path,
                    "select pKey0 from MyTableFAFU where col1=100",
                    "pKey0",
                    new object[] {"E1"});

                env.UndeployAll();
            }
Esempio n. 2
0
            public void Run(RegressionEnvironment env)
            {
                var path      = new RegressionPath();
                var eplWindow = "create window MyWindow#keepall as (TheString string);\n" + "on SupportBean merge MyWindow insert select TheString;\n";

                env.CompileDeploy(eplWindow, path);
                env.SendEventBean(new SupportBean("E1", 1));
                var eplFAF = "inlined_class \"\"\"\n" +
                             "namespace ${NAMESPACE} {\n" +
                             "    public class MyClass {\n" +
                             "        public static string DoIt(string parameter) {\n" +
                             "            return '>' + parameter + '<';\n" +
                             "        }\n" +
                             "    }\n" +
                             "}\n" +
                             "\"\"\"\n select ${NAMESPACE}.MyClass.DoIt(TheString) as c0 from MyWindow";
                var result = env.CompileExecuteFAF(
                    eplFAF.Replace("${NAMESPACE}", NamespaceGenerator.Create()),
                    path);

                Assert.AreEqual(">E1<", result.Array[0].Get("c0"));
                env.Milestone(0);

                result = env.CompileExecuteFAF(
                    eplFAF.Replace("${NAMESPACE}", NamespaceGenerator.Create()),
                    path);
                Assert.AreEqual(">E1<", result.Array[0].Get("c0"));
                env.UndeployAll();
            }
Esempio n. 3
0
            public void Run(RegressionEnvironment env)
            {
                RegressionPath path = new RegressionPath();
                string epl = "@Name('s0') create window MyWindow#keepall as SupportEventWithManyArray;\n" +
                             "insert into MyWindow select * from SupportEventWithManyArray;\n";
                env.CompileDeploy(epl, path);

                SendManyArray(env, new int[] {1, 2}, new int[] {3, 4});
                SendManyArray(env, new int[] {3, 4}, new int[] {1, 2});
                SendManyArray(env, new int[] {1, 2}, new int[] {3, 5});
                SendManyArray(env, new int[] {3, 4}, new int[] {1, 2});
                SendManyArray(env, new int[] {1, 2}, new int[] {3, 4});

                EPFireAndForgetQueryResult result = env.CompileExecuteFAF("select distinct IntOne from MyWindow", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    "IntOne".SplitCsv(),
                    new object[][] {
                        new object[] {new int[] {1, 2}},
                        new object[] {new int[] {3, 4}}
                    });

                result = env.CompileExecuteFAF("select distinct IntOne, IntTwo from MyWindow", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    "IntOne,IntTwo".SplitCsv(),
                    new object[][] {
                        new object[] {new int[] {1, 2}, new int[] {3, 4}},
                        new object[] {new int[] {3, 4}, new int[] {1, 2}},
                        new object[] {new int[] {1, 2}, new int[] {3, 5}}
                    });

                env.UndeployAll();
            }
Esempio n. 4
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create schema EmptyPropSchema()", path);
                env.CompileDeploy("@Name('window') create window EmptyPropWin#keepall as EmptyPropSchema", path);
                env.CompileDeploy("insert into EmptyPropWin() select null from SupportBean", path);

                env.SendEventBean(new SupportBean());

                var events = EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("window"));
                Assert.AreEqual(1, events.Length);
                Assert.AreEqual("EmptyPropWin", events[0].EventType.Name);

                // try fire-and-forget query
                env.CompileExecuteFAF("insert into EmptyPropWin select null", path);
                Assert.AreEqual(2, EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("window")).Length);
                env.CompileExecuteFAF("delete from EmptyPropWin", path); // empty window

                // try on-merge
                env.CompileDeploy(
                    "on SupportBean_S0 merge EmptyPropWin " +
                    "when not matched then insert select null",
                    path);
                env.SendEventBean(new SupportBean_S0(0));
                Assert.AreEqual(1, EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("window")).Length);

                // try on-insert
                env.CompileDeploy("on SupportBean_S1 insert into EmptyPropWin select null", path);
                env.SendEventBean(new SupportBean_S1(0));
                Assert.AreEqual(2, EPAssertionUtil.EnumeratorToArray(env.GetEnumerator("window")).Length);

                env.UndeployAll();
            }
        private void RunAssertionFireAndForget(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            var window = RegisterTypeSetMapData(env, path);

            // test no-criteria FAF
            var result = env.CompileExecuteFAF("select col1 from MyVDW vdw", path);
            AssertIndexSpec(window.LastRequestedLookup, "", "");
            Assert.AreEqual("MyVDW", window.LastRequestedLookup.NamedWindowName);
            Assert.AreEqual(-1, window.LastRequestedLookup.StatementId);
            Assert.IsNull(window.LastRequestedLookup.StatementName);
            Assert.IsNotNull(window.LastRequestedLookup.StatementAnnotations);
            Assert.IsTrue(window.LastRequestedLookup.IsFireAndForget);
            EPAssertionUtil.AssertProps(
                result.Array[0],
                new [] { "col1" },
                new object[] {"key1"});
            EPAssertionUtil.AssertEqualsExactOrder(new object[0], window.LastAccessKeys);

            // test single-criteria FAF
            result = env.CompileExecuteFAF("select col1 from MyVDW vdw where col1='key1'", path);
            AssertIndexSpec(window.LastRequestedLookup, "col1=(System.String)", "");
            EPAssertionUtil.AssertProps(
                result.Array[0],
                new [] { "col1" },
                new object[] {"key1"});
            EPAssertionUtil.AssertEqualsExactOrder(new object[] {"key1"}, window.LastAccessKeys);

            // test multi-criteria subquery
            result = env.CompileExecuteFAF(
                "select col1 from MyVDW vdw where col1='key1' and col2='key2' and col3 between 5 and 15",
                path);
            AssertIndexSpec(window.LastRequestedLookup, "col1=(System.String)|col2=(System.String)", "col3[,](System.Double)");
            EPAssertionUtil.AssertProps(
                result.Array[0],
                new [] { "col1" },
                new object[] {"key1"});
            EPAssertionUtil.AssertEqualsAnyOrder(
                new object[] {"key1", "key2", new VirtualDataWindowKeyRange(5d, 15d)},
                window.LastAccessKeys);

            // test multi-criteria subquery
            result = env.CompileExecuteFAF(
                "select col1 from MyVDW vdw where col1='key1' and col2>'Key0' and col3 between 5 and 15",
                path);
            AssertIndexSpec(window.LastRequestedLookup, "col1=(System.String)", "col3[,](System.Double)|col2>(System.String)");
            EPAssertionUtil.AssertProps(
                result.Array[0],
                new [] { "col1" },
                new object[] {"key1"});
            EPAssertionUtil.AssertEqualsAnyOrder(
                new object[] {"key1", new VirtualDataWindowKeyRange(5d, 15d), "Key0"},
                window.LastAccessKeys);

            env.UndeployAll();
        }
Esempio n. 6
0
        private static void AssertIndexChoice(
            RegressionEnvironment env,
            bool namedWindow,
            string[] indexes,
            object[] preloadedEvents,
            string datawindow,
            IndexAssertion[] assertions)
        {
            var path = new RegressionPath();
            var eplCreate = namedWindow
                ? "create window MyInfra." + datawindow + " as SupportSimpleBeanOne"
                : "create table MyInfra(S1 String primary key, I1 int primary key, D1 double primary key, L1 long primary key)";
            env.CompileDeploy(eplCreate, path);
            env.CompileDeploy("insert into MyInfra select S1,I1,D1,L1 from SupportSimpleBeanOne", path);
            foreach (var index in indexes) {
                env.CompileDeploy(index, path);
            }

            foreach (var @event in preloadedEvents) {
                env.SendEventBean(@event);
            }

            var count = 0;
            foreach (var assertion in assertions) {
                log.Info("======= Testing #" + count++);
                var epl = INDEX_CALLBACK_HOOK +
                          (assertion.Hint ?? "") +
                          "select * from MyInfra where " +
                          assertion.WhereClause;

                if (assertion.FafAssertion == null) {
                    try {
                        env.CompileExecuteFAF(epl, path);
                        Assert.Fail();
                    }
                    catch (Exception) {
                        // expected
                    }
                }
                else {
                    // assert index and access
                    var result = env.CompileExecuteFAF(epl, path);
                    SupportQueryPlanIndexHook.AssertFAFAndReset(
                        assertion.ExpectedIndexName,
                        assertion.IndexBackingClass);
                    assertion.FafAssertion.Invoke(result);
                }
            }

            env.UndeployAll();
        }
Esempio n. 7
0
            public void Run(RegressionEnvironment env)
            {
                // widen to long
                var path = new RegressionPath();
                var eplCreate = namedWindow
                    ? "create window MyInfraHBTW#keepall as (f1 long, f2 string)"
                    : "create table MyInfraHBTW as (f1 long primary key, f2 string primary key)";
                env.CompileDeploy(eplCreate, path);

                var eplInsert = "insert into MyInfraHBTW(f1, f2) select LongPrimitive, TheString from SupportBean";
                env.CompileDeploy(eplInsert, path);

                env.CompileDeploy("create index MyInfraHBTWIndex1 on MyInfraHBTW(f1 btree)", path);
                var fields = new [] { "f1","f2" };

                SendEventLong(env, "E1", 10L);
                var result = env.CompileExecuteFAF("select * from MyInfraHBTW where f1>9", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {10L, "E1"}});

                // SODA
                var epl = "create index IX1 on MyInfraHBTW(f1, f2 btree)";
                env.EplToModelCompileDeploy(epl, path);

                // SODA with unique
                var eplUnique = "create unique index IX2 on MyInfraHBTW(f1)";
                env.EplToModelCompileDeploy(eplUnique, path);

                // coerce to short
                var eplCreateTwo = namedWindow
                    ? "create window MyInfraHBTWTwo#keepall as (f1 short, f2 string)"
                    : "create table MyInfraHBTWTwo as (f1 short primary key, f2 string primary key)";
                env.CompileDeploy(eplCreateTwo, path);

                var eplInsertTwo =
                    "insert into MyInfraHBTWTwo(f1, f2) select ShortPrimitive, TheString from SupportBean";
                env.CompileDeploy(eplInsertTwo, path);
                env.CompileDeploy("create index MyInfraHBTWTwoIndex1 on MyInfraHBTWTwo(f1 btree)", path);

                SendEventShort(env, "E1", 2);

                result = env.CompileExecuteFAF("select * from MyInfraHBTWTwo where f1>=2", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {(short) 2, "E1"}});

                env.UndeployAll();
            }
Esempio n. 8
0
        private static void RunAssertionFireAndForgetInsertUpdateDelete(
            RegressionEnvironment env,
            RegressionPath path,
            object[][] expectedType)
        {
            var result = env.CompileExecuteFAF("insert into MyTable(key) values ('dummy')", path);
            AssertEventType(result.EventType, expectedType);

            result = env.CompileExecuteFAF("delete from MyTable where key = 'dummy'", path);
            AssertEventType(result.EventType, expectedType);

            result = env.CompileExecuteFAF("update MyTable set key='dummy' where key='dummy'", path);
            AssertEventType(result.EventType, expectedType);
        }
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create table MyTable(k1 string primary key, v1 string)", path);
                env.CompileExecuteFAF("insert into MyTable select 'x' as k1, 'y' as v1", path);
                env.CompileExecuteFAF("insert into MyTable select 'a' as k1, 'b' as v1", path);

                var epl = "@Name('s0') on SupportBean_S0 as `order` select v1 from MyTable where `order`.P00 = k1";
                env.CompileDeploy(epl, path).AddListener("s0");

                env.SendEventBean(new SupportBean_S0(1, "a"));
                Assert.AreEqual("b", env.Listener("s0").AssertOneGetNewAndReset().Get("v1"));

                env.UndeployAll();
            }
Esempio n. 10
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var stmtTextCreateOne = namedWindow
                    ? "create window MyInfraLC#keepall as (f1 string, f2 int, f3 string, f4 string)"
                    : "create table MyInfraLC as (f1 string primary key, f2 int primary key, f3 string primary key, f4 string primary key)";
                env.CompileDeploy(stmtTextCreateOne, path);
                env.CompileDeploy(
                    "insert into MyInfraLC(f1, f2, f3, f4) select TheString, IntPrimitive, '>'||TheString||'<', '?'||TheString||'?' from SupportBean",
                    path);

                env.SendEventBean(new SupportBean("E1", -4));

                env.Milestone(0);

                env.SendEventBean(new SupportBean("E1", -2));
                env.SendEventBean(new SupportBean("E1", -3));

                env.CompileDeploy("create index MyInfraLCIndex on MyInfraLC(f2, f3, f1)", path);
                var fields = new [] { "f1","f2","f3","f4" };

                env.Milestone(1);

                var result = env.CompileExecuteFAF("select * from MyInfraLC where f3='>E1<' order by f2 asc", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {
                        new object[] {"E1", -4, ">E1<", "?E1?"}, new object[] {"E1", -3, ">E1<", "?E1?"},
                        new object[] {"E1", -2, ">E1<", "?E1?"}
                    });

                env.UndeployAll();
            }
Esempio n. 11
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindowMerge#keepall as (p0 string, p1 string)", path);
                env.CompileExecuteFAF("insert into MyWindowMerge select 'a' as p0, 'b' as p1", path);
                env.CompileDeploy(
                    "on SupportBean_S0 merge MyWindowMerge as `order` when matched then update set `order`.p1 = `order`.p0",
                    path);
                env.CompileDeploy("on SupportBean_S1 update MyWindowMerge as `order` set p0 = 'x'", path);

                AssertFAF(env, path, "MyWindowMerge", "a", "b");

                env.SendEventBean(new SupportBean_S0(1));
                AssertFAF(env, path, "MyWindowMerge", "a", "a");

                env.Milestone(0);

                env.SendEventBean(new SupportBean_S1(1, "x"));
                AssertFAF(env, path, "MyWindowMerge", "x", "a");

                env.CompileDeploy(
                        "@Name('s0') on SupportBean select `order`.p0 as c0 from MyWindowMerge as `order`",
                        path)
                    .AddListener("s0");

                env.SendEventBean(new SupportBean());
                Assert.AreEqual("x", env.Listener("s0").AssertOneGetNewAndReset().Get("c0"));

                env.UndeployAll();
            }
Esempio n. 12
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeployWBusPublicType("create schema Geofence(x double, y double, vin string)", path);

                env.CompileDeploy(
                    "create table Regions(regionId string primary key, rx double, ry double, rwidth double, rheight double)",
                    path);
                env.CompileDeploy(
                    "create index RectangleIndex on Regions((rx, ry, rwidth, rheight) mxcifquadtree(0, 0, 10, 12))",
                    path);
                env.CompileDeploy(
                    "@Name('s0') " +
                    IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                    "on Geofence as vin insert into VINWithRegion select regionId, vin from Regions where rectangle(rx, ry, rwidth, rheight).intersects(rectangle(vin.x, vin.y, 0, 0))",
                    path);
                env.AddListener("s0");

                SupportQueryPlanIndexHook.AssertOnExprTableAndReset(
                    "RectangleIndex",
                    "non-unique hash={} btree={} advanced={mxcifquadtree(rx,ry,rwidth,rheight)}");

                env.CompileExecuteFAF("insert into Regions values ('R1', 2, 2, 5, 5)", path);
                env.SendEventMap(CollectionUtil.PopulateNameValueMap("x", 3d, "y", 3d, "vin", "V1"), "Geofence");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"vin", "regionId"},
                    new object[] {"V1", "R1"});

                env.UndeployAll();
            }
Esempio n. 13
0
 private static void RunAssertionFAF(
     RegressionEnvironment env,
     RegressionPath path,
     double x,
     double y,
     double width,
     double height,
     bool expected)
 {
     var result = env.CompileExecuteFAF(
         IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
         "select Id as c0 from MyTable where rectangle(tx, ty, tw, th).intersects(rectangle(" +
         x +
         ", " +
         y +
         ", " +
         width +
         ", " +
         height +
         "))",
         path);
     SupportQueryPlanIndexHook.AssertFAFAndReset("MyIdxCIFQuadTree", "EventTableQuadTreeMXCIF");
     if (expected) {
         EPAssertionUtil.AssertPropsPerRowAnyOrder(
             result.Array,
             new[] {"c0"},
             new[] {
                 new object[] {"R1"}
             });
     }
     else {
         Assert.AreEqual(0, result.Array.Length);
     }
 }
Esempio n. 14
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                // Prepare
                env.CompileDeploy("create table MyTable (sumint sum(int))", path);
                env.CompileDeploy(
                    "@Name('into') into table MyTable select sum(IntPrimitive) as sumint from SupportBean",
                    path);
                env.SendEventBean(new SupportBean("E1", 100));
                env.SendEventBean(new SupportBean("E2", 101));
                env.UndeployModuleContaining("into");

                // join simple
                env.CompileDeploy("@Name('join') select sumint from MyTable, SupportBean", path).AddListener("join");
                env.SendEventBean(new SupportBean());
                Assert.AreEqual(201, env.Listener("join").AssertOneGetNewAndReset().Get("sumint"));
                env.UndeployModuleContaining("join");

                // test regular columns inserted-into
                env.CompileDeploy("create table SecondTable (a string, b int)", path);
                env.CompileExecuteFAF("insert into SecondTable values ('a1', 10)", path);
                env.CompileDeploy("@Name('s0')select a, b from SecondTable, SupportBean", path).AddListener("s0");
                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"a", "b"},
                    new object[] {"a1", 10});

                env.UndeployAll();
            }
Esempio n. 15
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var epl = "create window MyWindow#keepall as (key string, anint int);\n" +
                          "insert into MyWindow(key, anint) select Id, Value from SupportIdAndValueEvent;\n" +
                          "@Name('s0') select exists (select sum(anint) from MyWindow group by key) as c0," +
                          "not exists (select sum(anint) from MyWindow group by key) as c1 from SupportValueEvent;\n";
                env.CompileDeploy(epl, path).AddListener("s0");
                var fields = new[] {"c0", "c1"};

                SendVEAndAssert(
                    env,
                    fields,
                    new object[] {false, true});

                env.SendEventBean(new SupportIdAndValueEvent("E1", 19));
                SendVEAndAssert(
                    env,
                    fields,
                    new object[] {true, false});

                env.CompileExecuteFAF("delete from MyWindow", path);

                SendVEAndAssert(
                    env,
                    fields,
                    new object[] {false, true});

                env.UndeployAll();
            }
Esempio n. 16
0
            public void Run(RegressionEnvironment env)
            {
                RegressionPath path = new RegressionPath();
                string stmtTextCreate = namedWindow
                    ? "@Name('create') create window MyInfra#keepall() as (Value int)"
                    : "@Name('create') create table MyInfra(Value int)";
                env.CompileDeploy(stmtTextCreate, path).AddListener("create");
                env.CompileExecuteFAF("insert into MyInfra select 0 as Value", path);

                string epl = "on SupportBean update MyInfra set Value = (select sum(Value) as c0 from SupportEventWithIntArray#keepall group by Array)";
                env.CompileDeploy(epl, path);

                env.SendEventBean(new SupportEventWithIntArray("E1", new int[] {1, 2}, 10));
                env.SendEventBean(new SupportEventWithIntArray("E2", new int[] {1, 2}, 11));

                env.Milestone(0);
                AssertUpdate(env, 21);

                env.SendEventBean(new SupportEventWithIntArray("E3", new int[] {1, 2}, 12));
                AssertUpdate(env, 33);

                env.Milestone(1);

                env.SendEventBean(new SupportEventWithIntArray("E4", new int[] {1}, 13));
                AssertUpdate(env, null);

                env.UndeployAll();
            }
Esempio n. 17
0
            public void Run(RegressionEnvironment env)
            {
                string[] fields = {"TheString", "IntPrimitive"};
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindow#keepall as select * from SupportBean", path);
                env.CompileDeploy("insert into MyWindow select * from SupportBean", path);

                env.SendEventBean(new SupportBean("E1", 1));
                env.SendEventBean(new SupportBean("E1", 2));

                env.Milestone(0);

                env.SendEventBean(new SupportBean("E2", 2));
                env.SendEventBean(new SupportBean("E1", 1));

                var query = "select distinct TheString, IntPrimitive from MyWindow order by TheString, IntPrimitive";
                var result = env.CompileExecuteFAF(query, path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {"E1", 1}, new object[] {"E1", 2}, new object[] {"E2", 2}});

                env.CompileDeploy(
                        "@Name('s0') on SupportBean_A select distinct TheString, IntPrimitive from MyWindow order by TheString, IntPrimitive asc",
                        path)
                    .AddListener("s0");

                env.SendEventBean(new SupportBean_A("x"));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").LastNewData,
                    fields,
                    new[] {new object[] {"E1", 1}, new object[] {"E1", 2}, new object[] {"E2", 2}});

                env.UndeployAll();
            }
Esempio n. 18
0
 private static void AssertCount(
     RegressionEnvironment env,
     RegressionPath path,
     long i)
 {
     Assert.AreEqual(i, env.CompileExecuteFAF("select count(*) as c0 from MyWindow", path).Array[0].Get("c0"));
 }
Esempio n. 19
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "create table MyTable(" +
                    "thewin window(*) @type('SupportBean')," +
                    "thesort sorted(IntPrimitive desc) @type('SupportBean')" +
                    ")",
                    path);

                env.CompileDeploy(
                    "into table MyTable " +
                    "select window(sb.*) as thewin, sorted(sb.*) as thesort " +
                    "from SupportBean_S0#lastevent, SupportBean#keepall as sb",
                    path);
                env.SendEventBean(new SupportBean_S0(1));

                var sb1 = new SupportBean("E1", 1);
                env.SendEventBean(sb1);

                env.Milestone(0);

                var sb2 = new SupportBean("E2", 2);
                env.SendEventBean(sb2);

                var result = env.CompileExecuteFAF("select * from MyTable", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    new[] {"thewin", "thesort"},
                    new[] {
                        new object[] {new[] {sb1, sb2}, new[] {sb2, sb1}}
                    });

                env.UndeployAll();
            }
Esempio n. 20
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindow#keepall as (p0 string, p1 int);", path);
                env.CompileDeploy("create unique index MyIndex on MyWindow(p0);", path);
                env.CompileDeploy(
                    INDEX_CALLBACK_HOOK +
                    "@Name('s0') on SupportBean_S0 as S0 select p0, p1 from MyWindow as win where win.p0 = S0.P00;",
                    path);
                env.AddListener("s0");

                SupportQueryPlanIndexHook.AssertOnExprTableAndReset(
                    "MyIndex",
                    "unique hash={p0(string)} btree={} advanced={}");

                env.CompileExecuteFAF("insert into MyWindow select 'a' as p0, 1 as p1", path);

                env.SendEventBean(new SupportBean_S0(1, "a"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new[] {"p0", "p1"},
                    new object[] {"a", 1});

                env.UndeployAll();
            }
Esempio n. 21
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var epl =
                    "create table RectangleTable(Id string primary key, rx double, ry double, rw double, rh double);\n" +
                    "create index MyIndex on RectangleTable((rx,ry,rw,rh) mxcifquadtree(0,0,100,100,4,20));\n" +
                    "insert into RectangleTable select Id, X as rx, Y as ry, Width as rw, Height as rh from SupportSpatialEventRectangle;\n" +
                    "@Name('out') on SupportSpatialAABB as aabb select pt.Id as c0 from RectangleTable as pt where rectangle(rx,ry,rw,rh).intersects(rectangle(X,Y,Width,Height));\n";
                env.CompileDeploy(epl, path).AddListener("out");

                SendEventRectangle(env, "P1", 80, 80, 1, 1);
                SendEventRectangle(env, "P2", 81, 80, 1, 1);
                SendEventRectangle(env, "P3", 80, 81, 1, 1);
                SendEventRectangle(env, "P4", 80, 80, 1, 1);
                SendEventRectangle(env, "P5", 45, 55, 1, 1);
                AssertRectanglesManyRow(env, env.Listener("out"), BOXES, null, null, "P5", "P1,P2,P3,P4", "P5");

                env.Milestone(0);

                AssertRectanglesManyRow(env, env.Listener("out"), BOXES, null, null, "P5", "P1,P2,P3,P4", "P5");
                env.CompileExecuteFAF("delete from RectangleTable where Id = 'P4'", path);
                AssertRectanglesManyRow(env, env.Listener("out"), BOXES, null, null, "P5", "P1,P2,P3", "P5");

                env.Milestone(1);

                AssertRectanglesManyRow(env, env.Listener("out"), BOXES, null, null, "P5", "P1,P2,P3", "P5");

                env.UndeployAll();
            }
Esempio n. 22
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindowFAF#keepall as (p0 string, p1 string)", path);
                env.CompileExecuteFAF("insert into MyWindowFAF select 'a' as p0, 'b' as p1", path);
                AssertFAF(env, path, "MyWindowFAF", "a", "b");

                env.CompileExecuteFAF("update MyWindowFAF as `order` set `order`.p0 = `order`.p1", path);
                AssertFAF(env, path, "MyWindowFAF", "b", "b");

                env.Milestone(0);

                env.CompileExecuteFAF("delete from MyWindowFAF as `order` where `order`.p0 = 'b'", path);
                Assert.AreEqual(0, env.CompileExecuteFAF("select * from MyWindowFAF", path).Array.Length);

                env.UndeployAll();
            }
Esempio n. 23
0
 private void Insert(
     RegressionEnvironment env,
     RegressionPath path,
     string k,
     int v)
 {
     env.CompileExecuteFAF("insert into MyInfra(k,v) values (" + k + "," + v + ")", path);
 }
Esempio n. 24
0
 private static void RunAssertionFireAndForgetSelectStar(
     RegressionEnvironment env,
     RegressionPath path,
     object[][] expectedType,
     object[] rowValues)
 {
     var result = env.CompileExecuteFAF("select * from MyTable where key = 'G1'", path);
     AssertEventTypeAndEvent(result.EventType, expectedType, result.Array[0].Underlying, rowValues);
 }
Esempio n. 25
0
 private static void AssertFAFNot(
     RegressionEnvironment env,
     RegressionPath path,
     String epl)
 {
     String faf = "@Hint('index(MyInfraIndex, bust)') select * from MyInfra where " + epl;
     EPFireAndForgetQueryResult result = env.CompileExecuteFAF(faf, path);
     Assert.AreEqual(0, result.Array.Length);
 }
Esempio n. 26
0
 private static void AssertValuesIterate(
     RegressionEnvironment env,
     RegressionPath path,
     string name,
     string[] fields,
     object[][] objects)
 {
     var result = env.CompileExecuteFAF("select * from " + name, path);
     EPAssertionUtil.AssertPropsPerRowAnyOrder(result.Array, fields, objects);
 }
Esempio n. 27
0
 private static long GetCount(
     RegressionEnvironment env,
     RegressionPath path,
     string windowOrTableName)
 {
     return env.CompileExecuteFAF("select count(*) as c0 from " + windowOrTableName, path)
         .Array[0]
         .Get("c0")
         .AsInt64();
 }
Esempio n. 28
0
 private static void RunQueryAssertion(
     RegressionEnvironment env,
     RegressionPath path,
     string epl,
     string[] fields,
     object[][] expected)
 {
     var result = env.CompileExecuteFAF(epl, path);
     EPAssertionUtil.AssertPropsPerRow(result.Array, fields, expected);
 }
Esempio n. 29
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                // widen to long
                var stmtTextCreate = namedWindow
                    ? "create window MyInfraW#keepall as (f1 long, f2 string)"
                    : "create table MyInfraW as (f1 long primary key, f2 string primary key)";
                env.CompileDeploy(stmtTextCreate, path);
                env.CompileDeploy(
                    "insert into MyInfraW(f1, f2) select LongPrimitive, TheString from SupportBean",
                    path);
                env.CompileDeploy("create index MyInfraWIndex1 on MyInfraW(f1)", path);
                var fields = new [] { "f1","f2" };

                SendEventLong(env, "E1", 10L);

                var result = env.CompileExecuteFAF("select * from MyInfraW where f1=10", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {10L, "E1"}});

                // coerce to short
                stmtTextCreate = namedWindow
                    ? "create window MyInfraWTwo#keepall as (f1 short, f2 string)"
                    : "create table MyInfraWTwo as (f1 short primary key, f2 string primary key)";
                env.CompileDeploy(stmtTextCreate, path);
                env.CompileDeploy(
                    "insert into MyInfraWTwo(f1, f2) select ShortPrimitive, TheString from SupportBean",
                    path);
                env.CompileDeploy("create index MyInfraWTwoIndex1 on MyInfraWTwo(f1)", path);

                SendEventShort(env, "E1", 2);

                result = env.CompileExecuteFAF("select * from MyInfraWTwo where f1=2", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {(short) 2, "E1"}});

                env.UndeployAll();
            }
Esempio n. 30
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var stmtTextCreate = namedWindow
                    ? "create window MyInfraCI#keepall as (f1 string, f2 int, f3 string, f4 string)"
                    : "create table MyInfraCI as (f1 string primary key, f2 int, f3 string, f4 string)";
                env.CompileDeploy(stmtTextCreate, path);
                var compiledWindow = path.Compileds[0];
                env.CompileDeploy(
                    "insert into MyInfraCI(f1, f2, f3, f4) select TheString, IntPrimitive, '>'||TheString||'<', '?'||TheString||'?' from SupportBean",
                    path);
                env.CompileDeploy("@Name('indexOne') create index MyInfraCIIndex on MyInfraCI(f2, f3, f1)", path);
                var fields = new [] { "f1","f2","f3","f4" };

                env.SendEventBean(new SupportBean("E1", -2));

                var result = env.CompileExecuteFAF("select * from MyInfraCI where f3='>E1<'", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {"E1", -2, ">E1<", "?E1?"}});

                result = env.CompileExecuteFAF("select * from MyInfraCI where f3='>E1<' and f2=-2", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {"E1", -2, ">E1<", "?E1?"}});

                result = env.CompileExecuteFAF("select * from MyInfraCI where f3='>E1<' and f2=-2 and f1='E1'", path);
                EPAssertionUtil.AssertPropsPerRow(
                    result.Array,
                    fields,
                    new[] {new object[] {"E1", -2, ">E1<", "?E1?"}});

                env.UndeployModuleContaining("indexOne");

                // test SODA
                path.Clear();
                path.Add(compiledWindow);
                env.EplToModelCompileDeploy("create index MyInfraCIIndexTwo on MyInfraCI(f2, f3, f1)", path)
                    .UndeployAll();
            }