Esempio n. 1
0
            public void Run(RegressionEnvironment env)
            {
                var text = "module test.test1;\n" +
                           "create schema MyTypeOne(col1 string, col2 int);" +
                           "create window MyWindowOne#keepall as select * from MyTypeOne;" +
                           "insert into MyWindowOne select * from MyTypeOne;";
                env.CompileDeploy(text).UndeployAll();
                env.CompileDeploy(text).UndeployAll();
                text = "module test.test1;\n" +
                       "create schema MyTypeOne(col1 string, col2 int, col3 long);" +
                       "create window MyWindowOne#keepall as select * from MyTypeOne;" +
                       "insert into MyWindowOne select * from MyTypeOne;";
                env.CompileDeploy(text).UndeployAll();
                Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));

                // test on-merge
                var moduleString =
                    "@Name('S0') create window MyWindow#unique(IntPrimitive) as SupportBean;\n" +
                    "@Name('S1') on MyWindow insert into SecondStream select *;\n" +
                    "@Name('S2') on SecondStream merge MyWindow when matched then insert into ThirdStream select * then delete\n";
                var compiled = env.Compile(moduleString);
                env.Deploy(compiled).UndeployAll().Deploy(compiled).UndeployAll();

                // test table
                var moduleTableOne = "create table MyTable(c0 string, c1 string)";
                env.CompileDeploy(moduleTableOne).UndeployAll();
                var moduleTableTwo = "create table MyTable(c0 string, c1 string, c2 string)";
                env.CompileDeploy(moduleTableTwo).UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('out') expression myindex {pointregionquadtree(0, 0, 100, 100)}" +
                          "select p.Id as c0 from pattern [every p=SupportSpatialPoint -> every SupportSpatialAABB(point(p.Px, p.Py, filterindex:myindex).inside(rectangle(X, Y, Width, Height)))]";

                env.CompileDeploy(epl).AddListener("out");

                env.Milestone(0);

                SendPoint(env, "P0", 10, 10);
                SendPoint(env, "P1", 60, 60);
                SendPoint(env, "P2", 60, 10);
                SendPoint(env, "P3", 10, 60);
                SendPoint(env, "P4", 10, 10);
                Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                AssertRectanglesManyRow(env, env.Listener("out"), BOXES, "P0,P4", "P2", "P3", "P1", "P1");

                env.Milestone(1);

                Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                AssertRectanglesManyRow(env, env.Listener("out"), BOXES, "P0,P4", "P2", "P3", "P1", "P1");

                env.UndeployAll();
                Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
            }
Esempio n. 3
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('out') expression myindex {mxcifquadtree(0, 0, 100, 100)}" +
                          "select p.Id as c0 from pattern [every p=SupportSpatialEventRectangle -> every SupportSpatialAABB(rectangle(p.X, p.Y, p.Width, p.Height, filterindex:myindex).intersects(rectangle(X, Y, Width, Height)))]";
                env.CompileDeploy(epl).AddListener("out");
                env.Milestone(0);

                SendEventRectangle(env, "R0", 10, 10, 1, 1);
                SendEventRectangle(env, "R1", 60, 60, 1, 1);
                SendEventRectangle(env, "R2", 60, 10, 1, 1);
                SendEventRectangle(env, "R3", 10, 60, 1, 1);
                SendEventRectangle(env, "R4", 10, 10, 1, 1);
                Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                AssertRectanglesManyRow(env, env.Listener("out"), BOXES, "R0,R4", "R2", "R3", "R1", "R1");

                env.Milestone(1);

                Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                AssertRectanglesManyRow(env, env.Listener("out"), BOXES, "R0,R4", "R2", "R3", "R1", "R1");

                env.UndeployAll();
            }
Esempio n. 4
0
            public void Run(RegressionEnvironment env)
            {
                var milestone = new AtomicLong();
                var ctx = "CategorizedContext";
                var fields = new [] { "c0", "c1", "c2" };

                var epl = "@Name('context') create context " +
                          ctx +
                          " " +
                          "group IntPrimitive < 10 as cat1, " +
                          "group IntPrimitive between 10 and 20 as cat2, " +
                          "group IntPrimitive > 20 as cat3 " +
                          "from SupportBean;\n";
                epl += "@Name('s0') context CategorizedContext " +
                       "select context.name as c0, context.label as c1, sum(IntPrimitive) as c2 from SupportBean;\n";
                env.CompileDeploy(epl).AddListener("s0");

                Assert.AreEqual(3, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                AgentInstanceAssertionUtil.AssertInstanceCounts(env, "s0", 3, null, null, null);

                env.MilestoneInc(milestone);

                env.SendEventBean(new SupportBean("E1", 5));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {ctx, "cat1", 5});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    env.Statement("s0").GetSafeEnumerator(),
                    fields,
                    new[] {
                        new object[] {ctx, "cat1", 5},
                        new object[] {ctx, "cat2", null},
                        new object[] {ctx, "cat3", null}
                    });

                env.MilestoneInc(milestone);

                env.SendEventBean(new SupportBean("E2", 4));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {ctx, "cat1", 9});

                env.SendEventBean(new SupportBean("E3", 11));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {ctx, "cat2", 11});

                env.MilestoneInc(milestone);

                env.SendEventBean(new SupportBean("E4", 25));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {ctx, "cat3", 25});

                env.SendEventBean(new SupportBean("E5", 25));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {ctx, "cat3", 50});

                env.MilestoneInc(milestone);

                env.SendEventBean(new SupportBean("E6", 3));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {ctx, "cat1", 12});

                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    env.Statement("s0").GetSafeEnumerator(),
                    fields,
                    new[] {
                        new object[] {ctx, "cat1", 12},
                        new object[] {ctx, "cat2", 11},
                        new object[] {ctx, "cat3", 50}
                    });

                Assert.AreEqual(1, SupportContextMgmtHelper.GetContextCount(env));
                Assert.AreEqual(3, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));

                env.UndeployModuleContaining("s0");

                Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                Assert.AreEqual(0, SupportContextMgmtHelper.GetContextCount(env));
            }
Esempio n. 5
0
            public void Run(RegressionEnvironment env)
            {
                // Comment-in to see CRC32 code.
                for (var i = 0; i < 10; i++) {
                    var key = "E" + i;
                    var code = SupportHashCodeFuncGranularCRC32.ComputeCRC32(key) % 4;
                    var hashCode = i.GetHashCode() % 4;
                    //System.out.println(key + " code " + code + " hashCode " + hashCode);
                }

                var path = new RegressionPath();
                var ctx = "HashSegmentedContext";
                var milestone = new AtomicLong();

                // test CRC32 Hash
                var eplCtx = "@Name('context') create context " +
                             ctx +
                             " as " +
                             "coalesce consistent_hash_crc32(TheString) from SupportBean " +
                             "granularity 4 " +
                             "preallocate";
                env.CompileDeploy(eplCtx, path);

                var eplStmt = "@Name('s0') context " +
                              ctx +
                              " " +
                              "select context.name as c0, TheString as c1, sum(IntPrimitive) as c2 from SupportBean#keepall group by TheString";
                env.CompileDeploy(eplStmt, path).AddListener("s0");
                Assert.AreEqual(4, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                AgentInstanceAssertionUtil.AssertInstanceCounts(env, "s0", 4, null, null, null);

                TryAssertionHash(env, milestone, "s0", ctx); // equivalent to: SupportHashCodeFuncGranularCRC32(4)
                Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                path.Clear();

                // test same with SODA
                env.EplToModelCompileDeploy(eplCtx, path);
                env.CompileDeploy(eplStmt, path).AddListener("s0");
                TryAssertionHash(env, milestone, "s0", ctx);
                path.Clear();

                // test with Java-hashCode String hash
                env.CompileDeploy(
                    "@Name('context') create context " +
                    ctx +
                    " " +
                    "coalesce hash_code(TheString) from SupportBean " +
                    "granularity 6 " +
                    "preallocate",
                    path);

                env.CompileDeploy(
                    "@Name('s0') context " +
                    ctx +
                    " " +
                    "select context.name as c0, TheString as c1, sum(IntPrimitive) as c2 from SupportBean#keepall group by TheString",
                    path);
                env.AddListener("s0");
                Assert.AreEqual(6, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                AgentInstanceAssertionUtil.AssertInstanceCounts(env, "s0", 6, null, null, null);

                TryAssertionHash(env, milestone, "s0", ctx);
                Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                path.Clear();

                // test no pre-allocate
                env.CompileDeploy(
                    "@Name('context') create context " +
                    ctx +
                    " " +
                    "coalesce hash_code(TheString) from SupportBean " +
                    "granularity 16",
                    path);

                env.CompileDeploy(
                    "@Name('s0') context " +
                    ctx +
                    " " +
                    "select context.name as c0, TheString as c1, sum(IntPrimitive) as c2 from SupportBean#keepall group by TheString",
                    path);
                env.AddListener("s0");
                Assert.AreEqual(1, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));
                AgentInstanceAssertionUtil.AssertInstanceCounts(env, "s0", 0, null, null, null);

                TryAssertionHash(env, milestone, "s0", ctx);
                Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env));

                env.UndeployAll();
            }