public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>();
            epService.EPAdministrator.Configuration.AddEventType(typeof(MyCountAccessEvent));
            // prepare
            PreloadData(epService, false);

            // test join
            string eplJoin  = "select * from SupportBean_S0 as s0 unidirectional, AWindow(p00='x') as aw where aw.id = s0.id";
            var    listener = new SupportUpdateListener();

            epService.EPAdministrator.CreateEPL(eplJoin).Events += listener.Update;
            if (!InstrumentationHelper.ENABLED)
            {
                Assert.AreEqual(2, MyCountAccessEvent.GetAndResetCountGetterCalled());
            }

            epService.EPRuntime.SendEvent(new SupportBean_S0(-1, "x"));
            Assert.IsTrue(listener.GetAndClearIsInvoked());

            // test subquery no-index-share
            string eplSubqueryNoIndexShare = "select (select id from AWindow(p00='x') as aw where aw.id = s0.id) " +
                                             "from SupportBean_S0 as s0 unidirectional";

            epService.EPAdministrator.CreateEPL(eplSubqueryNoIndexShare).Events += listener.Update;
            if (!InstrumentationHelper.ENABLED)
            {
                Assert.AreEqual(2, MyCountAccessEvent.GetAndResetCountGetterCalled());
            }

            epService.EPRuntime.SendEvent(new SupportBean_S0(-1, "x"));

            // test subquery with index share
            epService.EPAdministrator.DestroyAllStatements();
            PreloadData(epService, true);

            string eplSubqueryWithIndexShare = "select (select id from AWindow(p00='x') as aw where aw.id = s0.id) " +
                                               "from SupportBean_S0 as s0 unidirectional";

            epService.EPAdministrator.CreateEPL(eplSubqueryWithIndexShare).Events += listener.Update;
            if (!InstrumentationHelper.ENABLED)
            {
                Assert.AreEqual(2, MyCountAccessEvent.GetAndResetCountGetterCalled());
            }

            epService.EPRuntime.SendEvent(new SupportBean_S0(-1, "x"));
            Assert.IsTrue(listener.IsInvoked);
        }
        public void TestLateStartIndex()
        {
            // prepare
            PreloadData(false);

            // test join
            string eplJoin = "select * from SupportBean_S0 as s0 unidirectional, AWindow(p00='x') as aw where aw.id = s0.id";

            _epService.EPAdministrator.CreateEPL(eplJoin).AddListener(_listener);
            if (!InstrumentationHelper.ENABLED)
            {
                Assert.AreEqual(2, MyCountAccessEvent.GetAndResetCountGetterCalled());
            }

            _epService.EPRuntime.SendEvent(new SupportBean_S0(-1, "x"));
            Assert.IsTrue(_listener.GetAndClearIsInvoked());

            // test subquery no-index-share
            string eplSubqueryNoIndexShare = "select (select id from AWindow(p00='x') as aw where aw.id = s0.id) " +
                                             "from SupportBean_S0 as s0 unidirectional";

            _epService.EPAdministrator.CreateEPL(eplSubqueryNoIndexShare).AddListener(_listener);
            if (!InstrumentationHelper.ENABLED)
            {
                Assert.AreEqual(2, MyCountAccessEvent.GetAndResetCountGetterCalled());
            }

            _epService.EPRuntime.SendEvent(new SupportBean_S0(-1, "x"));

            // test subquery with index share
            _epService.EPAdministrator.DestroyAllStatements();
            PreloadData(true);

            string eplSubqueryWithIndexShare = "select (select id from AWindow(p00='x') as aw where aw.id = s0.id) " +
                                               "from SupportBean_S0 as s0 unidirectional";

            _epService.EPAdministrator.CreateEPL(eplSubqueryWithIndexShare).AddListener(_listener);
            if (!InstrumentationHelper.ENABLED)
            {
                Assert.AreEqual(2, MyCountAccessEvent.GetAndResetCountGetterCalled());
            }

            _epService.EPRuntime.SendEvent(new SupportBean_S0(-1, "x"));
            Assert.IsTrue(_listener.IsInvoked);
        }
        private void PreloadData(bool indexShare)
        {
            string createEpl = "create window AWindow.win:keepall() as MyCountAccessEvent";

            if (indexShare)
            {
                createEpl = "@Hint('enable_window_subquery_indexshare') " + createEpl;
            }

            _epService.EPAdministrator.CreateEPL(createEpl);
            _epService.EPAdministrator.CreateEPL("insert into AWindow select * from MyCountAccessEvent");
            _epService.EPAdministrator.CreateEPL("create index I1 on AWindow(p00)");
            MyCountAccessEvent.GetAndResetCountGetterCalled();
            for (int i = 0; i < 100; i++)
            {
                _epService.EPRuntime.SendEvent(new MyCountAccessEvent(i, "E" + i));
            }
            _epService.EPRuntime.SendEvent(new MyCountAccessEvent(-1, "x"));
            if (!InstrumentationHelper.ENABLED)
            {
                Assert.AreEqual(101, MyCountAccessEvent.GetAndResetCountGetterCalled());
            }
        }