Example #1
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);
     }
 }
Example #2
0
        private void AssertIndexChoice(
            EPServiceProvider epService,
            bool namedWindow,
            string[] indexes,
            object[] preloadedEvents,
            string datawindow,
            IndexAssertion[] assertions)
        {
            string eplCreate = namedWindow ?
                               "create window MyInfra." + datawindow + " as SSB1" :
                               "create table MyInfra(s1 string primary key, i1 int primary key, d1 double primary key, l1 long primary key)";

            epService.EPAdministrator.CreateEPL(eplCreate);
            epService.EPAdministrator.CreateEPL("insert into MyInfra select s1,i1,d1,l1 from SSB1");
            foreach (string index in indexes)
            {
                epService.EPAdministrator.CreateEPL(index);
            }
            foreach (Object @event in preloadedEvents)
            {
                epService.EPRuntime.SendEvent(@event);
            }

            int count = 0;

            foreach (IndexAssertion assertion in assertions)
            {
                Log.Info("======= Testing #" + count++);
                string epl = INDEX_CALLBACK_HOOK +
                             (assertion.Hint == null ? "" : assertion.Hint) +
                             "select * from MyInfra where " + assertion.WhereClause;
                EPOnDemandQueryResult result;
                try {
                    result = epService.EPRuntime.ExecuteQuery(epl);
                } catch (EPStatementException ex) {
                    if (assertion.EventSendAssertion == null)
                    {
                        // no assertion, expected
                        Assert.IsTrue(ex.Message.Contains("index hint busted"));
                        continue;
                    }
                    throw new EPRuntimeException("Unexpected statement exception: " + ex.Message, ex);
                }

                // assert index and access
                SupportQueryPlanIndexHook.AssertFAFAndReset(assertion.ExpectedIndexName, assertion.IndexBackingClass);
                assertion.FAFAssertion.Invoke(result);
            }

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false);
        }
Example #3
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();
        }
Example #4
0
        private void RunAssertionFAF(EPServiceProvider epService, double x, double y, double width, double height, bool expected)
        {
            var result = epService.EPRuntime.ExecuteQuery(IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "select id as c0 from MyTable where rectangle(tx, ty, tw, th).intersects(rectangle(" + x + ", " + y + ", " + width + ", " + height + "))");

            SupportQueryPlanIndexHook.AssertFAFAndReset("MyIdxCIFQuadTree", "EventTableQuadTreeMXCIFImpl");
            if (expected)
            {
                EPAssertionUtil.AssertPropsPerRowAnyOrder(result.Array, "c0".Split(','), new object[][] { new object[] { "R1" } });
            }
            else
            {
                Assert.AreEqual(0, result.Array.Length);
            }
        }
Example #5
0
        private void RunAssertionEventIndexTableFireAndForget(EPServiceProvider epService)
        {
            epService.EPAdministrator.CreateEPL("create table MyTable(id string primary key, tx double, ty double)");
            epService.EPAdministrator.CreateEPL("insert into MyTable select id, px as tx, py as ty from SupportSpatialPoint");
            epService.EPRuntime.SendEvent(new SupportSpatialPoint("P1", 50d, 50d));
            epService.EPRuntime.SendEvent(new SupportSpatialPoint("P2", 49d, 49d));
            epService.EPAdministrator.CreateEPL("create index MyIdxWithExpr on MyTable( (tx, ty) pointregionquadtree(0, 0, 100, 100))");

            var result = epService.EPRuntime.ExecuteQuery(IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "select id as c0 from MyTable where point(tx, ty).inside(rectangle(45, 45, 10, 10))");

            SupportQueryPlanIndexHook.AssertFAFAndReset("MyIdxWithExpr", "EventTableQuadTreePointRegionImpl");
            EPAssertionUtil.AssertPropsPerRowAnyOrder(result.Array, "c0".Split(','), new object[][] { new object[] { "P1" }, new object[] { "P2" } });

            epService.EPAdministrator.DestroyAllStatements();
        }